Module Test Error (Failed to load ApplicationContext)

Hello Every one,

This is a probleme i have when tryin to install my module in the local repository :slight_smile:

ject(AbstractBeanFactory.java:291) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistr y.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBe an(AbstractBeanFactory.java:288) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean (AbstractBeanFactory.java:190) at org.springframework.beans.factory.support.DefaultListableBeanFactory. preInstantiateSingletons(DefaultListableBeanFactory.java:580) at org.springframework.context.support.AbstractApplicationContext.finish BeanFactoryInitialization(AbstractApplicationContext.java:895) at org.springframework.context.support.AbstractApplicationContext.refres h(AbstractApplicationContext.java:425) at org.springframework.test.context.support.AbstractGenericContextLoader .loadContext(AbstractGenericContextLoader.java:84) at org.springframework.test.context.support.AbstractGenericContextLoader .loadContext(AbstractGenericContextLoader.java:1) at org.springframework.test.context.TestContext.loadApplicationContext(T estContext.java:280) at org.springframework.test.context.TestContext.getApplicationContext(Te stContext.java:304) … 31 more Caused by: org.springframework.beans.factory.BeanCreationException: Error creati ng bean with name ‘org.springframework.transaction.interceptor.TransactionProxyF actoryBean#4afe268a’ defined in URL [file:/C:/openmrs/Transport/api/target/class es/moduleApplicationContext.xml]: Cannot create inner bean ‘transport.Transport. api.impl.TransportServiceImpl#7a52b16b’ of type [transport.Transport.api.impl.Tr ansportServiceImpl] while setting bean property ‘target’; nested exception is or g.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [transport.Transport.api.impl.TransportServiceImpl] for bean with name ‘transpor t.Transport.api.impl.TransportServiceImpl#7a52b16b’ defined in URL [file:/C:/ope nmrs/Transport/api/target/classes/moduleApplicationContext.xml]; nested exceptio n is java.lang.ClassNotFoundException: transport.Transport.api.impl.TransportSer viceImpl at org.springframework.beans.factory.support.BeanDefinitionValueResolver .resolveInnerBean(BeanDefinitionValueResolver.java:281) at org.springframework.beans.factory.support.BeanDefinitionValueResolver .resolveValueIfNecessary(BeanDefinitionValueResolver.java:120) at org.springframework.beans.factory.support.AbstractAutowireCapableBean Factory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1325) at org.springframework.beans.factory.support.AbstractAutowireCapableBean Factory.populateBean(AbstractAutowireCapableBeanFactory.java:1086) at org.springframework.beans.factory.support.AbstractAutowireCapableBean Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517) at org.springframework.beans.factory.support.AbstractAutowireCapableBean Factory.createBean(AbstractAutowireCapableBeanFactory.java:456) at org.springframework.beans.factory.support.BeanDefinitionValueResolver .resolveInnerBean(BeanDefinitionValueResolver.java:270) … 49 more Caused by: org.springframework.beans.factory.CannotLoadBeanClassException: Canno t find class [transport.Transport.api.impl.TransportServiceImpl] for bean with n ame ‘transport.Transport.api.impl.TransportServiceImpl#7a52b16b’ defined in URL [file:/C:/openmrs/Transport/api/target/classes/moduleApplicationContext.xml]; ne sted exception is java.lang.ClassNotFoundException: transport.Transport.api.impl .TransportServiceImpl at org.springframework.beans.factory.support.AbstractBeanFactory.resolve BeanClass(AbstractBeanFactory.java:1250) at org.springframework.beans.factory.support.AbstractAutowireCapableBean Factory.createBean(AbstractAutowireCapableBeanFactory.java:433) at org.springframework.beans.factory.support.BeanDefinitionValueResolver .resolveInnerBean(BeanDefinitionValueResolver.java:270) … 55 more Caused by: java.lang.ClassNotFoundException: transport.Transport.api.impl.Transp ortServiceImpl at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at org.openmrs.util.OpenmrsClassLoader.loadClass(OpenmrsClassLoader.java :160) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) at org.springframework.util.ClassUtils.forName(ClassUtils.java:257) at org.springframework.beans.factory.support.AbstractBeanDefinition.reso lveBeanClass(AbstractBeanDefinition.java:408) at org.springframework.beans.factory.support.AbstractBeanFactory.doResol veBeanClass(AbstractBeanFactory.java:1271) at org.springframework.beans.factory.support.AbstractBeanFactory.resolve BeanClass(AbstractBeanFactory.java:1242) … 57 more Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 32.263 sec <<< F AILURE! shouldSetupContext(org.openmrs.module.Transport.api.TransportServiceTest) Time elapsed: 30.232 sec <<< ERROR! java.lang.IllegalStateException: Failed to load ApplicationContext at org.springframework.test.context.TestContext.getApplicationContext(Te stContext.java:308) at org.springframework.test.context.support.DependencyInjectionTestExecu tionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:10 9) at org.springframework.test.context.support.DependencyInjectionTestExecu tionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:7 5) at org.springframework.test.context.TestContextManager.prepareTestInstan ce(TestContextManager.java:321) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.creat eTest(SpringJUnit4ClassRunner.java:220) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.run ReflectiveCall(SpringJUnit4ClassRunner.java:301) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCal lable.java:15) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.metho dBlock(SpringJUnit4ClassRunner.java:303) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runCh ild(SpringJUnit4ClassRunner.java:240) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRun ner.java:50) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184) at org.springframework.test.context.junit4.statements.RunBeforeTestClass Callbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.ja va:31) at org.springframework.test.context.junit4.statements.RunAfterTestClassC allbacks.evaluate(RunAfterTestClassCallbacks.java:70) at org.junit.runners.ParentRunner.run(ParentRunner.java:236) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(S pringJUnit4ClassRunner.java:180) at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provide r.java:252) at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4 Provider.java:141) at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider .java:112) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl. java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces sorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray( ReflectionUtils.java:189) at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke (ProviderFactory.java:165) at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(Provi derFactory.java:85) at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(Fork edBooter.java:115) at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java: 75) Caused by: org.springframework.beans.factory.BeanCreationException: Error creati ng bean with name ‘serviceContext$child#1’ defined in URL [file:/C:/openmrs/Tran sport/api/target/classes/moduleApplicationContext.xml]: Cannot create inner bean ‘org.springframework.transaction.interceptor.TransactionProxyFactoryBean#4afe26 8a’ of type [org.springframework.transaction.interceptor.TransactionProxyFactory Bean] 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.TransactionProxyFactoryB ean#4afe268a’ defined in URL [file:/C:/openmrs/Transport/api/target/classes/modu leApplicationContext.xml]: Cannot create inner bean ‘transport.Transport.api.imp l.TransportServiceImpl#7a52b16b’ of type [transport.Transport.api.impl.Transport ServiceImpl] while setting bean property ‘target’; nested exception is org.sprin gframework.beans.factory.CannotLoadBeanClassException: Cannot find class [transp ort.Transport.api.impl.TransportServiceImpl] for bean with name ‘transport.Trans port.api.impl.TransportServiceImpl#7a52b16b’ defined in URL [file:/C:/openmrs/Tr ansport/api/target/classes/moduleApplicationContext.xml]; nested exception is ja va.lang.ClassNotFoundException: transport.Transport.api.impl.TransportServiceImp l at org.springframework.beans.factory.support.BeanDefinitionValueResolver .resolveInnerBean(BeanDefinitionValueResolver.java:281) at org.springframework.beans.factory.support.BeanDefinitionValueResolver .resolveValueIfNecessary(BeanDefinitionValueResolver.java:120) at org.springframework.beans.factory.support.BeanDefinitionValueResolver .resolveManagedList(BeanDefinitionValueResolver.java:353) at org.springframework.beans.factory.support.BeanDefinitionValueResolver .resolveValueIfNecessary(BeanDefinitionValueResolver.java:153) at org.springframework.beans.factory.support.AbstractAutowireCapableBean Factory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1325) at org.springframework.beans.factory.support.AbstractAutowireCapableBean Factory.populateBean(AbstractAutowireCapableBeanFactory.java:1086) at org.springframework.beans.factory.support.AbstractAutowireCapableBean Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517) at org.springframework.beans.factory.support.AbstractAutowireCapableBean Factory.createBean(AbstractAutowireCapableBeanFactory.java:456) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getOb ject(AbstractBeanFactory.java:291) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistr y.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBe an(AbstractBeanFactory.java:288) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean (AbstractBeanFactory.java:190) at org.springframework.beans.factory.support.DefaultListableBeanFactory. preInstantiateSingletons(DefaultListableBeanFactory.java:580) at org.springframework.context.support.AbstractApplicationContext.finish BeanFactoryInitialization(AbstractApplicationContext.java:895) at org.springframework.context.support.AbstractApplicationContext.refres h(AbstractApplicationContext.java:425) at org.springframework.test.context.support.AbstractGenericContextLoader .loadContext(AbstractGenericContextLoader.java:84) at org.springframework.test.context.support.AbstractGenericContextLoader .loadContext(AbstractGenericContextLoader.java:1) at org.springframework.test.context.TestContext.loadApplicationContext(T estContext.java:280) at org.springframework.test.context.TestContext.getApplicationContext(Te stContext.java:304) … 31 more Caused by: org.springframework.beans.factory.BeanCreationException: Error creati ng bean with name ‘org.springframework.transaction.interceptor.TransactionProxyF actoryBean#4afe268a’ defined in URL [file:/C:/openmrs/Transport/api/target/class es/moduleApplicationContext.xml]: Cannot create inner bean ‘transport.Transport. api.impl.TransportServiceImpl#7a52b16b’ of type [transport.Transport.api.impl.Tr ansportServiceImpl] while setting bean property ‘target’; nested exception is or g.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [transport.Transport.api.impl.TransportServiceImpl] for bean with name ‘transpor t.Transport.api.impl.TransportServiceImpl#7a52b16b’ defined in URL [file:/C:/ope nmrs/Transport/api/target/classes/moduleApplicationContext.xml]; nested exceptio n is java.lang.ClassNotFoundException: transport.Transport.api.impl.TransportSer viceImpl at org.springframework.beans.factory.support.BeanDefinitionValueResolver .resolveInnerBean(BeanDefinitionValueResolver.java:281) at org.springframework.beans.factory.support.BeanDefinitionValueResolver .resolveValueIfNecessary(BeanDefinitionValueResolver.java:120) at org.springframework.beans.factory.support.AbstractAutowireCapableBean Factory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1325) at org.springframework.beans.factory.support.AbstractAutowireCapableBean Factory.populateBean(AbstractAutowireCapableBeanFactory.java:1086) at org.springframework.beans.factory.support.AbstractAutowireCapableBean Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517) at org.springframework.beans.factory.support.AbstractAutowireCapableBean Factory.createBean(AbstractAutowireCapableBeanFactory.java:456) at org.springframework.beans.factory.support.BeanDefinitionValueResolver .resolveInnerBean(BeanDefinitionValueResolver.java:270) … 49 more Caused by: org.springframework.beans.factory.CannotLoadBeanClassException: Canno t find class [transport.Transport.api.impl.TransportServiceImpl] for bean with n ame ‘transport.Transport.api.impl.TransportServiceImpl#7a52b16b’ defined in URL [file:/C:/openmrs/Transport/api/target/classes/moduleApplicationContext.xml]; ne sted exception is java.lang.ClassNotFoundException: transport.Transport.api.impl .TransportServiceImpl at org.springframework.beans.factory.support.AbstractBeanFactory.resolve BeanClass(AbstractBeanFactory.java:1250) at org.springframework.beans.factory.support.AbstractAutowireCapableBean Factory.createBean(AbstractAutowireCapableBeanFactory.java:433) at org.springframework.beans.factory.support.BeanDefinitionValueResolver .resolveInnerBean(BeanDefinitionValueResolver.java:270) … 55 more Caused by: java.lang.ClassNotFoundException: transport.Transport.api.impl.Transp ortServiceImpl at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at org.openmrs.util.OpenmrsClassLoader.loadClass(OpenmrsClassLoader.java :160) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) at org.springframework.util.ClassUtils.forName(ClassUtils.java:257) at org.springframework.beans.factory.support.AbstractBeanDefinition.reso lveBeanClass(AbstractBeanDefinition.java:408) at org.springframework.beans.factory.support.AbstractBeanFactory.doResol veBeanClass(AbstractBeanFactory.java:1271) at org.springframework.beans.factory.support.AbstractBeanFactory.resolve BeanClass(AbstractBeanFactory.java:1242) … 57 more

Results :

Tests in error: shouldSetupContext(org.openmrs.module.Transport.api.TransportServiceTest): Fai led to load ApplicationContext

Tests run: 1, Failures: 0, Errors: 1, Skipped: 0

[INFO] ------------------------------------------------------------------------ [INFO] Reactor Summary: [INFO] [INFO] Transport Module … SUCCESS [ 1.303 s] [INFO] Transport Module API … FAILURE [01:00 min] [INFO] Transport Module OMOD … SKIPPED [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 01:02 min [INFO] Finished at: 2016-05-10T15:18:59-05:00 [INFO] Final Memory: 24M/134M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2. 12.4:test (default-test) on project Transport-api: There are test failures. [ERROR] [ERROR] Please refer to C:\openmrs\Transport\api\target\surefire-reports for the individual test results. [ERROR] -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit ch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please rea d the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureExc eption [ERROR] [ERROR] After correcting the problems, you can resume the build with the command

[ERROR] mvn -rf :Transport-api

C:\openmrs\Transport>

Can anyone help me? Thanks

Your module is failing to build:

[INFO] BUILD FAILURE

due to a failing test:

Tests in error: shouldSetupContext(org.openmrs.module.Transport.api.TransportServiceTest): Fai led to load ApplicationContext

You need to either fix or disable the test.

Looks like you’re missing transport.Transport.api.impl.TransportServiceImpl on the classpath

To add to this, I believe that Wilkin (please correct me if I’m wrong @wdessin ) simply created this new module using the OpenMRS SDK and was attempting to build it without modification.

Wilkin, can you list the exact steps you followed to generate the module?

(One issue may be to make you use the full openmrs namespace for the package name, ie org.openmrs.module.transport, if you didn’t previously)

Thanks! Mark

Thanks to reply.

@mogoodrich I created the server using 1- mvn openmrs-sdk:setup-platform -DserverId=mirebalais -Dversion=1.10.4

2- I created the module using this command inside the module folder mvn openmrs-sdk:create-platform-module 3- I try to install the module in my local repository first and i get this error Inside the module folder i make mvn clean install

this class is in my classpath
 **transport.Transport.api.impl.TransportServiceImpl**

I also try to use this command to create a module : mvn openmrs-sdk:create-module

But when I install it on both local repository and server with no probleme but it can’t start with this error :

Module transport cannot be started because it requires the following module(s): org.openmrs.module.uiframework 3.2 Please install and start these modules first.

Thanks

Hello, It was a bad understanding. I hurt when I answered the questions created a module. So the package name was a mistake.

Thanks, Wilkin.