Troubleshooting OpenMRS


Contents

XSN Upload: Invalid byte 2 of 2-byte UTF-8 sequence.

Information
A fatal error occurs when rebuilding a form.
 [Fatal Error] FormEntry.xsd:2975:100: Invalid byte 2 of 2-byte UTF-8 sequence.
 ERROR - PublishInfoPath.determineForm(386) |2007-06-20 13:30:47,967| Error parsing form data
 org.xml.sax.SAXParseException: Invalid byte 2 of 2-byte UTF-8 sequence.
   at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
   at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
   at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:172)
   at org.openmrs.module.formentry.PublishInfoPath.determineForm(PublishInfoPath.java:364)
   at org.openmrs.module.formentry.PublishInfoPath.publishXSN(PublishInfoPath.java:161)
   at org.openmrs.module.formentry.PublishInfoPath.publishXSN(PublishInfoPath.java:132)
   at org.openmrs.module.formentry.PublishInfoPath.publishXSN(PublishInfoPath.java:104)
   at org.openmrs.module.formentry.web.FormDownloadServlet.doGet(FormDownloadServlet.java:199) 
Solution
This error is caused when the DOMParser encounters an apostrophe in the FormEntry.xsd (concept_name.name, concept_name.description). The current workaround is to remove apostrophes from these fields. However, we need to be able to support apostrophes. See Ticket 416 for more information.

XSN Upload: java.lang.IllegalArgumentException: File cannot be null

Information
This error occurs on Linux versions running cabextract 1.1.
 DEBUG - FormEntryUtil.createTempDirectory(354) |2007-06-20 10:37:12,915| Successfully created temporary directory: /var/tmp/UPLOADEDXSN1182350232915
 DEBUG - PublishInfoPath.publishXSN(124) |2007-06-20 10:37:12,915| Temp publish dir: /var/tmp/UPLOADEDXSN1182350232915
 DEBUG - PublishInfoPath.publishXSN(154) |2007-06-20 10:37:12,916| publishing xsn at: /var/tmp/UPLOADEDXSN1182350232915/upload27656.xsn
 DEBUG - FormEntryUtil.createTempDirectory(354) |2007-06-20 10:37:12,916| Successfully created temporary directory: /var/tmp/XSN1182350232916
 DEBUG - FormEntryUtil.execCmd(298) |2007-06-20 10:37:12,917| executing command: /usr/bin/cabextract -d /var/tmp/XSN1182350232916 /var/tmp/UPLOADEDXSN1182350232915/upload27656.xsn
 DEBUG - FormEntryUtil.execCmd(320) |2007-06-20 10:37:12,957| execCmd output: Extracting cabinet: /var/tmp/UPLOADEDXSN1182350232915/upload27656.xsn
 
 All done, errors in processing 1 file(s)
 
 DEBUG - DispatcherServlet.doDispatch(866) |2007-06-20 10:37:12,960| Cleared thread-bound request context: org.apache.catalina.connector.RequestFacade@782dadad
 DEBUG - FrameworkServlet.processRequest(413) |2007-06-20 10:37:12,961| Could not complete request
 java.lang.IllegalArgumentException: File cannot be null
   at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:201)
   at org.openmrs.module.formentry.PublishInfoPath.determineForm(PublishInfoPath.java:364)
   at org.openmrs.module.formentry.PublishInfoPath.publishXSN(PublishInfoPath.java:161)
   at org.openmrs.module.formentry.PublishInfoPath.publishXSN(PublishInfoPath.java:132)
   at org.openmrs.module.formentry.PublishInfoPath.publishXSN(PublishInfoPath.java:104)
   at org.openmrs.module.formentry.web.controller.XsnUploadFormController.onSubmit(XsnUploadFormController.java:52)
   at org.springframework.web.servlet.mvc.SimpleFormController.processFormSubmission(SimpleFormController.java:258)
   at org.springframework.web.servlet.mvc.AbstractFormController.handleRequestInternal(AbstractFormController.java:250)
   at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
   at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:45)
Solution
The latest version of cabextract supports UTF-8 filenames. Files with UTF-8 filenames can now be extracted correctly.
Step 1 - Check to see if you're running cabextract 1.1.
 $ cabextract -v 
 cabextract version 1.1
Step 2 - Upgrade to Cabextract 1.2
 $ wget http://www.cabextract.org.uk/cabextract-1.2.tar.gz
 $ tar -zxvf cabextract-1.2.tar.gz
 $ cd cabextract-1.2
 $ ./configure
 $ make
 $ make install

Schema: 'FormEntry.xsd' cannot be null

Information
WARN - ModuleUtil.expandJar(271) |2007-06-14 10:44:32,703| Unable to find: lib in file C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\openmrs\WEB-INF\coreModules\formentry-2.4.omod
 ERROR - StandardWrapperValve.invoke(222) |2007-06-14 10:45:20,765| Servlet.service() for servlet module_servlet threw exception
 java.io.IOException: Schema: 'FormEntry.xsd' cannot be null
   at org.openmrs.module.formentry.FormEntryUtil.compileXSN(FormEntryUtil.java:211)
   at org.openmrs.module.formentry.FormEntryUtil.getCurrentXSN(FormEntryUtil.java:168)
   at org.openmrs.module.formentry.web.FormDownloadServlet.doGet(FormDownloadServlet.java:193)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
Solution
Make sure the following properties are assigned appropriate values for your OpenMRS server:
 formentry.infopath_output_dir
 formentry.infopath_server_url
Example
 formentry.infopath_output_dir=c:/Documents and Settings/USERNAME/Application Data/OpenMRS/forms
 formentry.infopath_server_url=http://localhost:8080/openmrs

MakeCab has failed OR Schema: 'FormEntry.xsd' cannot be null

Information
MakeCab has failed because the generated 'new.xsn' file in the temp directory '/usr/local/tomcat/temp/XSN1193912054866' cannot be null.

OR

Information
An error appears in the catalina.out log similar to this...
ERROR - FormEntryUtil.execCmd(430) |2008-01-24 11:49:36,187| Error while executing command: '/usr/local/bin/cabextract -d /var/tmp/XSN1201193376118 /var/tmp/XSN -db-file1201193376117/tempContent.xsn' java.io.IOException: Cannot run program "/usr/local/bin/cabextract" (in director y "/var/tmp/XSN1201193376118"): java.io.IOException: error=2, No such file or directory
Solution
Make sure the following properties are assigned appropriate values for your OpenMRS server: (These should be added to the OpenMRS runtime properties.)
 formentry.cabextract_location
 formentry.lcab_location
Example
 formentry.cabextract_location=/usr/bin/cabextract
 formentry.lcab_location=/usr/bin/lcab

Forms are being submitted successfully, but not showing up in Patient Dashboard

Information
When forms are submitted, they are placed into the database's formentry_queue. OpenMRS runs a scheduled task, Process Form Entry Queue, every 30 seconds to process the forms from the database. If the form is processed (converted from XML to HL7) successfully, it is placed in formentry_archive and into hl7_in_queue. If it fails, the forms are placed in formentry_error.
Forms in the hl7_in_queue are processed by the Process HL7 Task every 30 seconds. Successful forms are placed in hl7_in_archive while failed forms go into hl7_in_error.
Solution
The first thing to do is to check the database for where your forms may be getting stuck. The following queries, should help
 # find items in queues
 select formentry_queue_id,date_created from formentry_queue order by date_created desc limit 10;
 select hl7_in_queue_id,date_created from hl7_in_queue order by date_created desc limit 10;
 
 # find last ten errors in form submission
 select formentry_error_id,date_created,error,error_details from formentry_error order by date_created desc limit 10;
 select hl7_in_error_id,date_created,error,error_details from hl7_in_error order by date_created desc limit 10;
If you are forms are stuck in formentry_queue or hl7_in_queue, check OpenMRS (Admin > Manage Scheduler) to make sure the scheduled tasks are set to start on startup and are running. If they are not, make sure the FormEntry module is deployed and active. If you forms are stuck in the formentry_error or hl7_in_error then read the error messages and Tomcat logs and work from there.
If you see the following message in the logs files
 org.openmrs.api.context.ContextAuthenticationException: Invalid username and/or password: XXXX
you must correctly set the global properties scheduler.username and scheduler.password to match the OpenMRS account which the scheduler must use to run automated tasks.
If you see the following message in the logs files
 ERROR - FormEntryQueueProcessor.transformFormEntryQueue(91) |2008-03-24 15:18:02,031| Error while parsing formentry (0)
 java.lang.RuntimeException: XPathFactory#newInstance() failed to create an XPath
 Factory for the default object model: http://java.sun.com/jaxp/xpath/dom with the 
 XPathFactoryConfigurationException: javax.xml.xpath.XPathFactoryConfigurationException: 
 No XPathFctory implementation found for the object model: http://java.sun.com/jaxp/xpath/dom
       at javax.xml.xpath.XPathFactory.newInstance(Unknown Source)
   org.openmrs.api.context.ContextAuthenticationException: Invalid username and/or password: XXXX
Check the xercesImpl.jar and xml-apis.jar in tomcat/common/endorsed, and delete from the tomcat directory. These are also located in the openmrs.war file.

FormEntry module tries to download XSN from different server

Information
When performing patient form entry use case, the downloaded form tries to open an InfoPath form on another server (URL is for different server).
Solution
This usually occurs if the XSN has been taken from a different server and imported into a new intance of OpenMRS. This is caused by an incorrect 'formentry.infopath_server_url' value (in global_property table) and/or if the XSN for the form has not be rebuilt to correct the server URL.


Example
Check the formentry.infopath_server_url global property to make sure it's pointing to the correct server.
 select * from global_property where property_name = 'formentry.infopath_server_url'
 
Rebuild XSNs
  1. Login as Admin
  2. Navigate to Manage Forms
  3. Click on Rebuild XSNs (note this will only rebuild published forms. If your forms are not published, you may have to view the schema for each form and rebuild XSN from that page)

OpenMRS modules and settings disappear and reappear on reboot

Information
A default Windows install of OpenMRS places its modules and properties files in "%APPDATA%\OpenMRS\". Where "APPDATA" is the home directory Application Data folder of the user that is running Tomcat. Chances are your install is like most Windows installs, so the OpenMRS folder will be "C:\Documents and Settings\Your Username\Application Data\OpenMRS\". It is often the case that this account is in the Administrators group.
Some Windows installs also have a default (but hidden) Administrator account (username: administrator, password: none) which under some circumstances can be used by Tomcat. In this case, the OpenMRS will be looking for its modules in the "C:\Application Data\OpenMRS\" folder. It will not find them there and thus modules and settings will not be loaded.
Solution
These problems stem from Windows services being run under the Local System account of the machine on which they are installed.
Configure the Apache Tomcat service to start under a specific user account rather than the default "Local System Account". This can be configured in the Services window in Control Panel, Administrative Tools. You should use the same user account when running the installer.

Image:ServicesLogOnAs.PNG


OpenMRS will not start anymore. There are non-module files in the modules directory; derby.log and/or velocity.log

Information
The BIRT Runtime creates various log files in the modules directory when the BIRT Module is stopped. OpenMRS won't start if there are non-modules in the modules directory. You may find a message in the event log similar to
 org.openmrs.module.ModuleException: Module file does not have the correct .omod file extension Module: derby.log
 org.openmrs.module.ModuleException: Module file does not have the correct .omod file extension Module: velocity.log
Solution
Delete the files in the modules directory which aren't modules with an .omod extension.
To prevent the derby.log from being created, delete the "org.apache.derby.core_10.1.2.1" directory, under the
 <PATH TO BIRT>/birt-runtime-2_2_0/ReportEngine/plugins/ directory.