Module: Atomfeed 1.0.12
System Version: OpenMRS Core 2.2 with Core at tags/2.2.0-20181112.082045-243.
I’m trying to add atomfeed to my server and getting the following error.
org.openmrs.module.ModuleException: Unable to start OpenMRS. Error thrown was: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'atomfeedController' defined in URL [jar:file:/home/tomcat7/.OpenMRS/.openmrs-lib-cache/atomfeed/atomfeed.jar!/org/openmrs/module/atomfeed/web/controller/AtomfeedController.class]: Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.openmrs.module.atomfeed.web.controller.AtomfeedController]: Constructor threw exception; nested exception is java.lang.NullPointerException
at org.openmrs.web.WebDaemon.startOpenmrs(WebDaemon.java:65)
at org.openmrs.web.Listener.contextInitialized(Listener.java:192)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5068)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5584)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:899)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:875)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1091)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1980)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: javax.servlet.ServletException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'atomfeedController' defined in URL [jar:file:/home/tomcat7/.OpenMRS/.openmrs-lib-cache/atomfeed/atomfeed.jar!/org/openmrs/module/atomfeed/web/controller/AtomfeedController.class]: Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.openmrs.module.atomfeed.web.controller.AtomfeedController]: Constructor threw exception; nested exception is java.lang.NullPointerException
at org.openmrs.web.Listener.startOpenmrs(Listener.java:259)
at org.openmrs.web.WebDaemon$1.run(WebDaemon.java:42)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'atomfeedController' defined in URL [jar:file:/home/tomcat7/.OpenMRS/.openmrs-lib-cache/atomfeed/atomfeed.jar!/org/openmrs/module/atomfeed/web/controller/AtomfeedController.class]: Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.openmrs.module.atomfeed.web.controller.AtomfeedController]: Constructor threw exception; nested exception is java.lang.NullPointerException
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:275)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1131)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1034)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:762)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
at org.openmrs.module.ModuleUtil.refreshApplicationContext(ModuleUtil.java:888)
at org.openmrs.module.web.WebModuleUtil.refreshWAC(WebModuleUtil.java:847)
at org.openmrs.web.Listener.performWebStartOfModules(Listener.java:632)
at org.openmrs.web.Listener.performWebStartOfModules(Listener.java:612)
at org.openmrs.web.Listener.startOpenmrs(Listener.java:251)
... 1 more
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.openmrs.module.atomfeed.web.controller.AtomfeedController]: Constructor threw exception; nested exception is java.lang.NullPointerException
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:163)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:122)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:267)
... 17 more
Caused by: java.lang.NullPointerException
at org.openmrs.api.context.ServiceContext.getRegisteredComponents(ServiceContext.java:916)
at org.openmrs.api.context.ServiceContext.getRegisteredComponents(ServiceContext.java:880)
at org.openmrs.api.context.Context.getRegisteredComponents(Context.java:1193)
at org.openmrs.module.atomfeed.api.utils.ContextUtils.getFirstRegisteredComponent(ContextUtils.java:38)
at org.openmrs.module.atomfeed.api.utils.ContextUtils.getAtomFeedClientHelper(ContextUtils.java:22)
at org.openmrs.module.atomfeed.web.controller.AtomfeedController.(AtomfeedController.java:35)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:147)
... 19 more
I’ve turned it off and on again. I tried removing OpenMRS completely (uninstalling the server, wiping the app data dir, and dropping the database) and reinstalling from scratch – didn’t help. I get this error regardless of whether I drop the omod in the modules/
directory or try to install it from the Admin UI.
The lines where the error occurs, ServiceContext.java:914-916 read
private <T> Map<String, T> getRegisteredComponents(ApplicationContext context, Class<T> type) {
Map<String, T> components = new HashMap<>();
Map registeredComponents = context.getBeansOfType(type);
specifically the last line, which would indicate that the context
getting passed in is null. It comes from ServiceContext.java:879-880, which is
public <T> List<T> getRegisteredComponents(Class<T> type) {
Map<String, T> m = getRegisteredComponents(applicationContext, type);
where applicationContext
is a private field:
public class ServiceContext implements ApplicationContextAware {
private ApplicationContext applicationContext;
To compound my confusion, loading atomfeed is working just fine on a different computer. The computer on which it is working is an SDK server. The computer on which I’m encountering this error is a Tomcat server, installed as a Debian bundle. I think that both are running the same version of OpenMRS Core.
Anyone have any ideas why applicationContext
might not be defined at the time Atomfeed wants to use it? Any guidance about how to debug this would be very welcome.