Modules loading order

**Application Name:**Platform Version Number: 1.11.7

Question: Hello, I’m trying to add a modules given in OpenSHR repository to my OpenMRS docker container. Module omod files are copied to the right directory, but modules didn’t start and errors are thrown:

ERROR - Listener.contextInitialized(188) |2017-06-06 09:58:11,682| Got exception while starting up: 
org.openmrs.module.ModuleException: Unable to start OpenMRS. Error thrown was: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'serviceContext$child#0' defined in URL [jar:file:/root/.OpenMRS/.openmrs-lib-cache/shr-cdahandler/lib/shr-cdahandler-api-0.6.0.jar!/moduleApplicationContext.xml]: Cannot create inner bean 'org.springframework.transaction.interceptor.TransactionProxyFactoryBean#41a7303f' of type [org.springframework.transaction.interceptor.TransactionProxyFactoryBean] while setting bean property 'moduleService' with key [1]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.interceptor.TransactionProxyFactoryBean#41a7303f' defined in URL [jar:file:/root/.OpenMRS/.openmrs-lib-cache/shr-cdahandler/lib/shr-cdahandler-api-0.6.0.jar!/moduleApplicationContext.xml]: Cannot create inner bean 'org.openmrs.module.shr.cdahandler.api.impl.CdaImportServiceImpl#b63bf58' of type [org.openmrs.module.shr.cdahandler.api.impl.CdaImportServiceImpl] while setting bean property 'target'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.openmrs.module.shr.cdahandler.api.impl.CdaImportServiceImpl#b63bf58' defined in URL [jar:file:/root/.OpenMRS/.openmrs-lib-cache/shr-cdahandler/lib/shr-cdahandler-api-0.6.0.jar!/moduleApplicationContext.xml]: Initialization of bean failed; nested exception is java.lang.LinkageError: loader constraint violation: loader (instance of org/openmrs/util/OpenmrsClassLoader) previously initiated loading for a different type with name "org/marc/everest/rmim/uv/cdar2/pocd_mt000040uv/ClinicalDocument"

Caused by: javax.servlet.ServletException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'serviceContext$child#0' defined in URL [jar:file:/root/.OpenMRS/.openmrs-lib-cache/shr-cdahandler/lib/shr-cdahandler-api-0.6.0.jar!/moduleApplicationContext.xml]: Cannot create inner bean 'org.springframework.transaction.interceptor.TransactionProxyFactoryBean#41a7303f' of type [org.springframework.transaction.interceptor.TransactionProxyFactoryBean] while setting bean property 'moduleService' with key [1]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.interceptor.TransactionProxyFactoryBean#41a7303f' defined in URL [jar:file:/root/.OpenMRS/.openmrs-lib-cache/shr-cdahandler/lib/shr-cdahandler-api-0.6.0.jar!/moduleApplicationContext.xml]: Cannot create inner bean 'org.openmrs.module.shr.cdahandler.api.impl.CdaImportServiceImpl#b63bf58' of type [org.openmrs.module.shr.cdahandler.api.impl.CdaImportServiceImpl] while setting bean property 'target'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.openmrs.module.shr.cdahandler.api.impl.CdaImportServiceImpl#b63bf58' defined in URL [jar:file:/root/.OpenMRS/.openmrs-lib-cache/shr-cdahandler/lib/shr-cdahandler-api-0.6.0.jar!/moduleApplicationContext.xml]: Initialization of bean failed; nested exception is java.lang.LinkageError: loader constraint violation: loader (instance of org/openmrs/util/OpenmrsClassLoader) previously initiated loading for a different type with name "org/marc/everest/rmim/uv/cdar2/pocd_mt000040uv/ClinicalDocument"

and so on…

Modules should be started in the specific order. Is a way to ensure this order of module loading order?

I’m using following versions of modules:

  • shr-atna-1.0.0
  • shr-contenthandler-3.0.0.omod
  • xds-b-repository-0.4.5.omod
  • shr-cdahandler-0.6.0.omod
  • shr-odd-0.5.1.omod

Additionally I’m using openhie-client-0.5 and webservices.rest-2.12 modules.

Sometimes all modules will start properly, but usually the errors given above are occurring.

Regards, Marcin

This looks like multiple instances of ClinicalDocument loaded by different class loaders. Try expand these .omod files and check the lib folder for libraries that should not be there.

Thanks for reply. Indeed some of libraries are redundant. I think this is the fault of openhie-client-0.5.omod file which is containing libraries occuring in two other modules. The most curious is that sometimes OpenMRS is starting without issues and next time the given error is present.

I tried to remove redundant libraries from omod files, but then i was getting “NoClassFoundException”. It seems like the loading order was random.

Is there a way to set a specific order of loading modules or should I try to resolve the libraries issues in some other way?

Can i have a look at the source of these modules?

Of course. Here are the repositories to modules I’m using:

In this repository is a tutorial with release pages with specific versions of modules. I’m also using a openhie-client module, which can be found here.

If you want, I can send you a zip with modules I’m using (can’t attach here).

Thanks, Marcin

Now you can send me the compiled modules zip.

Sorry for delay. You can find a package with modules on my Google Drive.

I see that you have the everest jars in more than one module. Can you ensure that you have them in only one module? For the rest of the modules, just set the maven scope to provided. To notice this, i extracted your omod files and checked the lib folder for each, to see the duplicated jars.

I’m trying to do that. I changed maven scope e.g. in

META-INF/maven/org.openmrs.module/shr-cdahandler-api/pom.xml

but error still occurs. Should I build this module from source code (some libraries are not longer available)?

I’ve added a <scope>provided</scope> first to shr modules, next I tried to change libraries in openhie-client module. Now I’m trying to add this scope to all of modules where duplicated libs exists.

Can you tell me what am I doing wrong?

Thanks for help, Marcin

You need to change the real source and build the modules from source.

I’m trying to build some modules, but some dependencies are no longer available. This can be a hard thing to do, but thanks for help. When I’ll build it, I’ll give you a feedback - I’m trying to build a openhie-client module first.