Error Importing Metadata Using Metadata Sharing Module on Platform 1.11.5

I am trying to import this packaged metadata into platform 1.11.5. Initially it appears as though everything is working fine until it stops with the exception shown below.

Fri Apr 29 17:33:20 EAT 2016 - Saving import state Fri Apr 29 17:33:20 EAT 2016 - Importing subpackage 1 of 1 Fri Apr 29 17:33:20 EAT 2016 - Resolving related items Fri Apr 29 17:33:24 EAT 2016 - Adjusting import settings Fri Apr 29 17:33:24 EAT 2016 - Loading existing items Fri Apr 29 17:33:24 EAT 2016 - Converting items Fri Apr 29 17:33:24 EAT 2016 - Setting audit fields Fri Apr 29 17:33:25 EAT 2016 - Merging items Fri Apr 29 17:33:25 EAT 2016 - Preparing items to save Fri Apr 29 17:33:25 EAT 2016 - Validating items Fri Apr 29 17:33:25 EAT 2016 - Saving items Fri Apr 29 17:34:30 EAT 2016 - Updating mappings Fri Apr 29 17:34:33 EAT 2016 - Import completed Fri Apr 29 17:34:33 EAT 2016 - Task failed

org.openmrs.module.metadatasharing.task.TaskException: Task failed at org.openmrs.module.metadatasharing.task.Task.log( at org.openmrs.module.metadatasharing.task.TaskEngine$ at java.util.concurrent.ThreadPoolExecutor.runWorker( at java.util.concurrent.ThreadPoolExecutor$ at Caused by: org.openmrs.module.metadatasharing.task.TaskException: Task failed … 4 more Caused by: org.springframework.transaction.UnexpectedRollbackException: Transaction rolled back because it has been marked as rollback-only at at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning( at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction( at org.springframework.transaction.interceptor.TransactionInterceptor.invoke( at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed( at org.springframework.aop.framework.JdkDynamicAopProxy.invoke( at com.sun.proxy.$Proxy3483.executeTask(Unknown Source) at org.openmrs.module.metadatasharing.task.TaskEngine$ … 3 more

English (United States) | English (United Kingdom) Last Build: 2016-03-30 08:36 Version: 1.11.5 Build 47f108

Looking into the tomcat logs shows exactly the same thing.

@raff would you be in position to point me in the right direction here?

There must be an error somewhere along the import and it isn’t logged properly. Due to that error the transaction has been marked as failed and rolled back.

You will have to run the import with a debugger attached and set some breakpoints in the execute method of the ImportPackageTask class to find out what exception caused rolling back the transaction.

@raff I figured I didn’t need to run the debugger after all because I was trying to import the package exported from 1.9.3 to 1.11.5 which may be the problem, but anyway I didn’t want to find out. Instead I with the help of @wyclif I got hold of the metadata exported from 1.11.5. Unfortunately I am still running into errors as shown in this stack trace

To reproduce this error follow the steps below:

  1. Spawn a 1.11.5 instance of OpenMRS (I am using legacy UI although I doubt if it matters!)

  2. Go to Administration, click “Import Metadata” under “Metadata sharing module” section. You should see a screen as shown below. Download and use this metadata package

  3. Click next where you will see a page as shown (i.e everything looks fine)

  4. Click next and choose “From Peer” option. You should see the page below.

  5. At this point when you click next you will see stack trace mentioned above.

I am still investigating the reason for this but it appears the query generator is having issues generating the right query.

I have no idea what is going on with my server instance I used for this exercise because trying to reproduce the same problem on a standalone reference application 2.3.1 does not work, that is the package is imported successfully!

The stacktrace reveals an actual bug in openmrs-core as “AND” is not escaped in the query and it is a reserved keyword. It needs to be fixed as described here

Created an issue at

To get you pass the error, you could try changing SULFADOXINE AND PYRIMETHAMINE to lowercase in xml inside the package.

But why don’t I experience the same behavior in standalone?!! This is puzzling!

Update: The Lucene error disappeared after changing the offending AND to lower case. However I am still not able to import concepts because the error for which this thread has been created (see first post) has re-surfaced. Nevertheless I realized we don’t actually need to import the package for us to be able to utilize the order entry API which was all along the goal of doing this.

Thanks for reporting back. I think the bug will only reveal itself, if you do not have “AND” in concept stop words, thus it worked on your standalone. Adding “AND” to concept stop words list from the management page should fix it as well.

1 Like

Hi,@raff, I added both AND and OR as stop words on my Ref App 2.4 standalone today but it still runs into the same issue. A workaround is to replace AND to lower case and as well as to replace OR to lower case or on the metadata.xml file.

@ayeung the fix is in platform 1.11.7 which is not yet released. I like your workaround. :smile: