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(ReflectUtils.java:386)
	at org.springframework.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:219)
	at org.springframework.cglib.proxy.Enhancer.createHelper(Enhancer.java:377)
	at org.springframework.cglib.proxy.Enhancer.createClass(Enhancer.java:317)
	at org.springframework.context.annotation.ConfigurationClassEnhancer.createClass(ConfigurationClassEnhancer.java:118)
	at org.springframework.context.annotation.ConfigurationClassEnhancer.enhance(ConfigurationClassEnhancer.java:92)
	at org.springframework.context.annotation.ConfigurationClassPostProcessor.enhanceConfigurationClasses(ConfigurationClassPostProcessor.java:358)
	at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanFactory(ConfigurationClassPostProcessor.java:244)
	at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:694)
	at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:633)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:461)
	at org.openmrs.module.ModuleUtil.refreshApplicationContext(ModuleUtil.java:832)
	at org.openmrs.module.web.WebModuleUtil.refreshWAC(WebModuleUtil.java:962)
	at org.openmrs.web.Listener.performWebStartOfModules(Listener.java:617)
	at org.openmrs.web.Listener.performWebStartOfModules(Listener.java:596)
	at org.openmrs.web.Listener.startOpenmrs(Listener.java:239)
	at org.openmrs.web.WebDaemon$1.run(WebDaemon.java:42)

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:

-Dspringloaded=inclusions=org.openmrs.module.moduleid..*

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. https://github.com/spring-projects/spring-loaded/issues/6

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 -Dxreports.development.directory=/Projects/openmrs/xreports