7

我有一个在 Tomcat 7 上运行的 Spring 应用程序。添加 WebSockets 后,我开始在undeployment期间在日志中看到以下错误。

除了日志和增加的取消部署时间(它等待超时)之外,一切正常。

添加的 WebSockets 代码没有什么花哨的。只是一个@Controller,一个子类AbstractWebSocketMessageBrokerConfigurer和一个子类AbstractSecurityWebSocketMessageBrokerConfigurer

怎么了?我不认为我缺少任何罐子。我可以在 .jar 中的 jar中看到org.springframework.context.support.DefaultLifecycleProcessor类。匿名类也在那里。spring-context-4.2.2-RELEASEWEB-INF/libDefaultLifecycleProcessor$1


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]
4

3 回答 3

2

您是否已将其打包为胖 jar,并且在关闭正在运行的应用程序之前重新部署更新的 jar?这就是发生在我身上的事情,因为我正在使用 ansible 来下载 fat jar,如果 jar 发生变化,则使用处理程序重新启动应用程序。

我通过先暂存新 jar 来解决它,如果它不同,则在复制暂存 jar 之前停止应用程序。

请参阅此处了解更多信息

于 2017-05-10T15:05:56.540 回答
0

这里的一般智慧是首先检查您的服务器日志(例如:catalina.out,如果是tomcat),而不是您的应用程序日志

在我的情况下,问题出在胖罐子上,因为它有多个 slf4j-log4j12 并且服务器日志中包含以下错误

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

通过排除解决了

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

从一个引起冲突的罐子里

于 2020-08-24T08:11:10.987 回答
0

我认为您缺少类路径上的 spring-websocket jar。此错误与 spring-context 库无关,启动/停止时的代码无法找到应该启动/停止的组件。正如您提到的 websockets,spring-websocket 必须为您解决问题。甚至是 org.springframework.integration 库。

于 2017-05-15T11:32:46.647 回答