NoClassDefFoundError: DefaultLifecycleProcessor$1 when undeplying spring-messaging application
Asked Answered
C

3

7

I have a Spring application running on Tomcat 7. After adding WebSockets I started to see the following errors in the logs during undeployment.

Other then the logs and increased time of undeployment (it waits for a timeout), it all works fine.

There is nothing fancy in the added WebSockets code. Just a single @Controller, one subclass of AbstractWebSocketMessageBrokerConfigurer and one subclass of AbstractSecurityWebSocketMessageBrokerConfigurer.

What's the matter? I don't think I'm missing any jars.. I could see org.springframework.context.support.DefaultLifecycleProcessor class in the jar spring-context-4.2.2-RELEASE which I have in my WEB-INF/lib. The anoymous class DefaultLifecycleProcessor$1 is there too.


14 Mar 2016 23:25:34,508  INFO  [context.support.DefaultLifecycleProcessor] Stopping beans in phase 2147483647
14 Mar 2016 23:25:34,508  DEBUG [context.support.DefaultLifecycleProcessor] Asking bean 'stompWebSocketHandlerMapping' of type [class org.springframework.web.socket.server.support.WebSocketHandlerMapping] to stop
14 Mar 2016 23:25:34,508  WARN  [context.support.DefaultLifecycleProcessor] Failed to stop bean 'stompWebSocketHandlerMapping'
java.lang.NoClassDefFoundError: org/springframework/context/support/DefaultLifecycleProcessor$1
    at org.springframework.context.support.DefaultLifecycleProcessor.doStop(DefaultLifecycleProcessor.java:229)
    at org.springframework.context.support.DefaultLifecycleProcessor.access$300(DefaultLifecycleProcessor.java:51)
    at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.stop(DefaultLifecycleProcessor.java:363)
    at org.springframework.context.support.DefaultLifecycleProcessor.stopBeans(DefaultLifecycleProcessor.java:202)
    at org.springframework.context.support.DefaultLifecycleProcessor.onClose(DefaultLifecycleProcessor.java:118)
    at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:969)
    at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:928)
    at org.springframework.web.servlet.FrameworkServlet.destroy(FrameworkServlet.java:828)
    at org.apache.catalina.core.StandardWrapper.unload(StandardWrapper.java:1481)
    at org.apache.catalina.core.StandardWrapper.stopInternal(StandardWrapper.java:1842)
    at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
    at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5647)
    at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
    at org.apache.catalina.core.ContainerBase.removeChild(ContainerBase.java:1028)
    at org.apache.catalina.startup.HostConfig.undeploy(HostConfig.java:1478)
    at org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1406)
    at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1626)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:328)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
    at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1374)
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1530)
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1540)
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1519)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: org.springframework.context.support.DefaultLifecycleProcessor$1
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1718)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1569)
    ... 25 more
14 Mar 2016 23:25:34,509  DEBUG [context.support.DefaultLifecycleProcessor] Asking bean 'subProtocolWebSocketHandler' of type [class org.springframework.web.socket.messaging.SubProtocolWebSocketHandler] to stop
14 Mar 2016 23:25:34,509  WARN  [context.support.DefaultLifecycleProcessor] Failed to stop bean 'subProtocolWebSocketHandler'
java.lang.NoClassDefFoundError: org/springframework/context/support/DefaultLifecycleProcessor$1
    at org.springframework.context.support.DefaultLifecycleProcessor.doStop(DefaultLifecycleProcessor.java:229)
    at org.springframework.context.support.DefaultLifecycleProcessor.access$300(DefaultLifecycleProcessor.java:51)
    at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.stop(DefaultLifecycleProcessor.java:363)
    at org.springframework.context.support.DefaultLifecycleProcessor.stopBeans(DefaultLifecycleProcessor.java:202)
    at org.springframework.context.support.DefaultLifecycleProcessor.onClose(DefaultLifecycleProcessor.java:118)
    at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:969)
    at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:928)
    at org.springframework.web.servlet.FrameworkServlet.destroy(FrameworkServlet.java:828)
    at org.apache.catalina.core.StandardWrapper.unload(StandardWrapper.java:1481)
    at org.apache.catalina.core.StandardWrapper.stopInternal(StandardWrapper.java:1842)
    at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
    at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5647)
    at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
    at org.apache.catalina.core.ContainerBase.removeChild(ContainerBase.java:1028)
    at org.apache.catalina.startup.HostConfig.undeploy(HostConfig.java:1478)
    at org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1406)
    at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1626)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:328)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
    at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1374)
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1530)
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1540)
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1519)
    at java.lang.Thread.run(Thread.java:745)
14 Mar 2016 23:25:34,509  DEBUG [context.support.DefaultLifecycleProcessor] Asking bean 'simpAnnotationMethodMessageHandler' of type [class org.springframework.web.socket.messaging.WebSocketAnnotationMethodMessageHandler] to stop
14 Mar 2016 23:25:34,509  WARN  [context.support.DefaultLifecycleProcessor] Failed to stop bean 'simpAnnotationMethodMessageHandler'
java.lang.NoClassDefFoundError: org/springframework/context/support/DefaultLifecycleProcessor$1
    at org.springframework.context.support.DefaultLifecycleProcessor.doStop(DefaultLifecycleProcessor.java:229)
    at org.springframework.context.support.DefaultLifecycleProcessor.access$300(DefaultLifecycleProcessor.java:51)
    at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.stop(DefaultLifecycleProcessor.java:363)
    at org.springframework.context.support.DefaultLifecycleProcessor.stopBeans(DefaultLifecycleProcessor.java:202)
    at org.springframework.context.support.DefaultLifecycleProcessor.onClose(DefaultLifecycleProcessor.java:118)
    at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:969)
    at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:928)
    at org.springframework.web.servlet.FrameworkServlet.destroy(FrameworkServlet.java:828)
    at org.apache.catalina.core.StandardWrapper.unload(StandardWrapper.java:1481)
    at org.apache.catalina.core.StandardWrapper.stopInternal(StandardWrapper.java:1842)
    at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
    at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5647)
    at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
    at org.apache.catalina.core.ContainerBase.removeChild(ContainerBase.java:1028)
    at org.apache.catalina.startup.HostConfig.undeploy(HostConfig.java:1478)
    at org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1406)
    at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1626)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:328)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
    at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1374)
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1530)
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1540)
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1519)
    at java.lang.Thread.run(Thread.java:745)
14 Mar 2016 23:25:34,509  DEBUG [context.support.DefaultLifecycleProcessor] Asking bean 'simpleBrokerMessageHandler' of type [class org.springframework.messaging.simp.broker.SimpleBrokerMessageHandler] to stop
14 Mar 2016 23:25:34,509  WARN  [context.support.DefaultLifecycleProcessor] Failed to stop bean 'simpleBrokerMessageHandler'
java.lang.NoClassDefFoundError: org/springframework/context/support/DefaultLifecycleProcessor$1
    at org.springframework.context.support.DefaultLifecycleProcessor.doStop(DefaultLifecycleProcessor.java:229)
    at org.springframework.context.support.DefaultLifecycleProcessor.access$300(DefaultLifecycleProcessor.java:51)
    at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.stop(DefaultLifecycleProcessor.java:363)
    at org.springframework.context.support.DefaultLifecycleProcessor.stopBeans(DefaultLifecycleProcessor.java:202)
    at org.springframework.context.support.DefaultLifecycleProcessor.onClose(DefaultLifecycleProcessor.java:118)
    at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:969)
    at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:928)
    at org.springframework.web.servlet.FrameworkServlet.destroy(FrameworkServlet.java:828)
    at org.apache.catalina.core.StandardWrapper.unload(StandardWrapper.java:1481)
    at org.apache.catalina.core.StandardWrapper.stopInternal(StandardWrapper.java:1842)
    at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
    at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5647)
    at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
    at org.apache.catalina.core.ContainerBase.removeChild(ContainerBase.java:1028)
    at org.apache.catalina.startup.HostConfig.undeploy(HostConfig.java:1478)
    at org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1406)
    at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1626)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:328)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
    at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1374)
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1530)
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1540)
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1519)
    at java.lang.Thread.run(Thread.java:745)
14 Mar 2016 23:25:34,510  DEBUG [context.support.DefaultLifecycleProcessor] Asking bean 'userDestinationMessageHandler' of type [class org.springframework.messaging.simp.user.UserDestinationMessageHandler] to stop
14 Mar 2016 23:25:34,510  WARN  [context.support.DefaultLifecycleProcessor] Failed to stop bean 'userDestinationMessageHandler'
java.lang.NoClassDefFoundError: org/springframework/context/support/DefaultLifecycleProcessor$1
    at org.springframework.context.support.DefaultLifecycleProcessor.doStop(DefaultLifecycleProcessor.java:229)
    at org.springframework.context.support.DefaultLifecycleProcessor.access$300(DefaultLifecycleProcessor.java:51)
    at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.stop(DefaultLifecycleProcessor.java:363)
    at org.springframework.context.support.DefaultLifecycleProcessor.stopBeans(DefaultLifecycleProcessor.java:202)
    at org.springframework.context.support.DefaultLifecycleProcessor.onClose(DefaultLifecycleProcessor.java:118)
    at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:969)
    at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:928)
    at org.springframework.web.servlet.FrameworkServlet.destroy(FrameworkServlet.java:828)
    at org.apache.catalina.core.StandardWrapper.unload(StandardWrapper.java:1481)
    at org.apache.catalina.core.StandardWrapper.stopInternal(StandardWrapper.java:1842)
    at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
    at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5647)
    at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
    at org.apache.catalina.core.ContainerBase.removeChild(ContainerBase.java:1028)
    at org.apache.catalina.startup.HostConfig.undeploy(HostConfig.java:1478)
    at org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1406)
    at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1626)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:328)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
    at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1374)
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1530)
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1540)
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1519)
    at java.lang.Thread.run(Thread.java:745)
14 Mar 2016 23:26:04,511  WARN  [context.support.DefaultLifecycleProcessor] Failed to shut down 5 beans with phase value 2147483647 within timeout of 30000: [stompWebSocketHandlerMapping, subProtocolWebSocketHandler, simpAnnotationMethodMessageHandler, simpleBrokerMessageHandler, userDestinationMessageHandler]
Carlitacarlo answered 15/3, 2016 at 21:42 Comment(1)
are yuo sure you are using the same spring version for all modules?Lourielouse
F
2

Have you packaged this as a fat jar, and are you redeploying the updated jar BEFORE shutting down the running app? That is what was happening to me, because I was using ansible to download the fat jar, with a handler to restart the app if the jar had changed.

I solved it by staging the new jar first, and if it is different, stopping the app before copying the staged jar.

See here for more info

Fleabane answered 10/5, 2017 at 15:5 Comment(0)
S
0

I think you are missing the spring-websocket jar on your classpath. This error is not related to the spring-context library, the code while starting/stopping isn't able to find a component which should be started/stopped. As you mentioned websockets, spring-websocket must do the trick for you. Or even the org.springframework.integration library.

Stalag answered 15/5, 2017 at 11:32 Comment(0)
S
0

A general wisdom here is to check your server logs first (ex: catalina.out in case of tomcat), instead of your application logs

In my case the issue was with the fat jar as it had multiple slf4j-log4j12 and the following error surrounded in server logs

Caused by: java.lang.IllegalArgumentException: LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. Either remove Logback or the competing implementation (class org.slf4j.impl.Log4jLoggerFactory loaded from jar:file:/myjar.jar!/lib/slf4j-log4j12-1.7.8.jar!/). If you are using Weblogic you will need to add 'org.slf4j' to prefer-application-packages in WEB-INF/weblogic.xml Object of class [org.slf4j.impl.Log4jLoggerFactory] must be an instance of class ch.qos.logback.classic.LoggerContext

which got resolved by exclusion of

<groupId>org.slf4j-log4j</groupId>
<artifactId>slf4j-log4j12</artifactId>

from one of the jar which was causing the conflict

Sky answered 24/8, 2020 at 8:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.