Troubleshooting Formentry Module

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

A fatal error occurs when rebuilding a form. [archive: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)
SolutionThis 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 TRAC-416 for more information.

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

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

(Note: Ubuntu repositories contain the latest cabextract: sudo apt-get install cabextract)

$ wget [http://www.cabextract.org.uk/cabextract-1.2.tar.gz|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

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 runtime properties are assigned appropriate values for your OpenMRS server:

formentry.infopath_server_url

Example:
formentry.infopath_server_url=[http://localhost:8080/openmrs|http://localhost:8080/openmrs]

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

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

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 lcab and cabextract are installed in your system. To do that on ubuntu run

]$ whereis lcab

]$whereis cabextract

If one or both of the above commands return empty result then it means you do not have lcab, cabextract or both depending on the results. If lcab is missing then run "sudo apt-get install lcab" , else if cabextract is missing run "sudo apt-get install cabextract" without quotes.

Make sure the following properties are assigned appropriate values for your OpenMRS server: (These should be added to theOpenMRS runtime properties.)

formentry.cabextract_location
formentry.lcab_location
Example

  1. (In your runtime properties file)
    formentry.cabextract_location=/usr/bin/cabextract
    formentry.lcab_location=/usr/bin/lcab

 

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

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. SolutionThe 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;

  1. 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 rumtime 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|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|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

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)