IllegalStateException: Cannot load configuration class: MetadataSharing

Hi, I recently tried to add spring-loaded to aid our development. But When I add the spring-loaded jar, I keep getting this error for metadatasharing module(1.1.9) and openmrs did not startup ( It throws ‘Unable to start OpenMRS: Scheduler service not found’ which was not the real cause).

ERROR [org.openmrs.web.Listener] java.lang.IllegalStateException: Cannot load configuration class: org.openmrs.module.metadatasharing.MetadataSharing17Configuration
2015-10-03 22:25:51,610 ERROR [org.openmrs.web.Listener] Unable to refresh the spring application context.  Root Cause was:
java.lang.NoSuchFieldError: r$sfields
	at org.openmrs.module.metadatasharing.MetadataSharing17Configuration$$EnhancerByCGLIB$$ae5743fa.<clinit>(<generated>)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Unknown Source)
	at org.springframework.cglib.core.ReflectUtils.defineClass(
	at org.springframework.cglib.core.AbstractClassGenerator.create(
	at org.springframework.cglib.proxy.Enhancer.createHelper(
	at org.springframework.cglib.proxy.Enhancer.createClass(
	at org.springframework.context.annotation.ConfigurationClassEnhancer.createClass(
	at org.springframework.context.annotation.ConfigurationClassEnhancer.enhance(
	at org.springframework.context.annotation.ConfigurationClassPostProcessor.enhanceConfigurationClasses(
	at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanFactory(
	at org.openmrs.module.ModuleUtil.refreshApplicationContext(
	at org.openmrs.module.web.WebModuleUtil.refreshWAC(
	at org.openmrs.web.Listener.performWebStartOfModules(
	at org.openmrs.web.Listener.performWebStartOfModules(
	at org.openmrs.web.Listener.startOpenmrs(
	at org.openmrs.web.WebDaemon$

This happens when spring application context is being refreshed.

And the command I used to add springloaded is -javaagent:/bahmni/springloaded-1.2.3.RELEASE.jar -noverify.

OpenMRS started up fine when I restarted OpenMRS without this module. Any idea about these errors?

Do you get the same with spring-loaded version 1.2.4? By the way, which version of the openmrs platform?

yes I get the same error with 1.2.4 but from MetadataSharing19Configuration class. We are using openmrs 1.11.

If you are trying to reload a particular module, try adding something like:


Replace moduleid with your actual moduleid and the see if the problem persists.

Used this option but it started throwing the error for the module I included. Seems like it needs some more investigation.

I got the same error but for a different class. What i did to solve it was to simply exclude it from the classes to be reloaded. So in your case, you will need to append this to the spring loaded argumements: ;exclusions=org.openmrs.module.metadatasharing.MetadataSharing17Configuration

The exclusions can be more than one and comma separated. They could be class or packages names. Below is just an example of what am using:

-javaagent:/Projects/springloaded-1.2.5.RELEASE.jar -noverify -Dspringloaded=inclusions=org.openmrs.module.xreports..*;exclusions=org.openmrs.module.xreports.web.XReportRenderer