Init spring application context in the contextInitialized method.
try {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
ctx.scan(configuration.getCommandScanPackage(), configuration.getServiceScanPackage());
ctx.refresh();
this.applicationContext = ctx;
} catch (Exception e) {
logger.error("Failed to init spring application context", e);
return;
}
Exception
2019-04-28 16:41:09,969 [WrapperSimpleAppMain] ERROR Failed to init spring application context
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'command1002': Lookup method resolution failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [com.hp.ucmdb.sock.command.Command1002] from ClassLoader [WebAppClassLoader=29448349@1c1589d]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:265)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineConstructorsFromBeanPostProcessors(AbstractAutowireCapableBeanFactory.java:1236)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1151)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:538)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:498)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:846)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:863)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546)
at com.microfocus.socketio.SocketIoListener.contextInitialized(SocketIoListener.java:37)
at org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:890)
at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:532)
at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:853)
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:344)
at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1515)
at org.eclipse.jetty.quickstart.QuickStartWebApp.startWebapp(QuickStartWebApp.java:131)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1477)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:785)
at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:261)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:545)
at org.eclipse.jetty.quickstart.QuickStartWebApp.doStart(QuickStartWebApp.java:201)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:133)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:115)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:167)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:133)
at org.eclipse.jetty.server.Server.start(Server.java:418)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:107)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
at org.eclipse.jetty.server.Server.doStart(Server.java:385)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at com.mercury.topaz.cmdb.server.manage.servlet.JettyManager.startServer(JettyManager.java:277)
at com.mercury.topaz.cmdb.server.manage.Framework.doStart0(Framework.java:253)
at com.mercury.topaz.cmdb.server.manage.Framework.access$100(Framework.java:113)
at com.mercury.topaz.cmdb.server.manage.Framework$2.executeInContext(Framework.java:232)
at com.mercury.topaz.cmdb.server.manage.Framework$2.executeInContext(Framework.java:229)
at com.mercury.topaz.cmdb.shared.manage.AuthorizationContextUtils.executeInSystemAuthorizationContext(AuthorizationContextUtils.java:24)
at com.mercury.topaz.cmdb.server.manage.Framework.start0(Framework.java:229)
at com.mercury.topaz.cmdb.server.manage.Framework.doStartUp(Framework.java:215)
at com.mercury.topaz.cmdb.server.manage.Framework.access$000(Framework.java:113)
at com.mercury.topaz.cmdb.server.manage.Framework$1.executeInContext(Framework.java:197)
at com.mercury.topaz.cmdb.server.manage.Framework$1.executeInContext(Framework.java:194)
at com.mercury.topaz.cmdb.shared.manage.AuthorizationContextUtils.executeInSystemAuthorizationContext(AuthorizationContextUtils.java:24)
at com.mercury.topaz.cmdb.server.manage.Framework.startUp(Framework.java:194)
at com.hp.ucmdb.server.Main.startFramework(Main.java:40)
at com.hp.ucmdb.server.Main.main(Main.java:26)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.tanukisoftware.wrapper.WrapperSimpleApp.run(WrapperSimpleApp.java:349)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalStateException: Failed to introspect Class [com.hp.ucmdb.sock.command.Command1002] from ClassLoader [WebAppClassLoader=29448349@1c1589d]
at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:680)
at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:577)
at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:562)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:248)
... 56 more
Caused by: java.lang.NoClassDefFoundError: com/hpe/ucmdb/changes/subscription/ModelChangeSubscriber
I thought the error caused by the classes loading order at the beginning.
When I checked the model-change.jar file, it didn't exist in the lib folder, I realized that it was the root cause.
Behavior
Init spring application context in the contextInitialized method.
Exception