关闭tomcat服务器时Spring集成的例外情况

时间:2012-11-15 14:26:06

标签: java jms spring-integration

我有一个在Tomcat 6上运行的Spring Integration应用程序。它有一个message-driven-channel-adapter,它与远程Active MQ服务器通信。到目前为止,我能够完成我的工作。

然而,当我关闭Tomcat时,我在catalina日志中无休止地循环:

Exception in thread   "org.springframework.jms.listener.DefaultMessageListenerContainer#0-178" Exception in thread "org.springframework.jms.listener.DefaultMessageListenerContainer#0-179" 

 java.lang.NullPointerException
    at org.apache.log4j.LogManager.getLogger(LogManager.java:188)
    at org.apache.log4j.Logger.getLogger(Logger.java:104)
    at org.apache.commons.logging.impl.Log4JLogger.getLogger(Log4JLogger.java:289)
    at org.apache.commons.logging.impl.Log4JLogger.trace(Log4JLogger.java:166)
    at org.springframework.jms.support.JmsUtils.closeMessageConsumer(JmsUtils.java:158)
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.clearResources(DefaultMessageListenerContainer.java:1111)
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:971)
    at java.lang.Thread.run(Thread.java:722)

java.lang.NullPointerException
    at org.apache.log4j.LogManager.getLogger(LogManager.java:188)
    at org.apache.log4j.Logger.getLogger(Logger.java:104)
    at org.apache.commons.logging.impl.Log4JLogger.getLogger(Log4JLogger.java:289)
    at org.apache.commons.logging.impl.Log4JLogger.trace(Log4JLogger.java:166)
    at org.springframework.jms.support.JmsUtils.closeSession(JmsUtils.java:115)
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.clearResources(DefaultMessageListenerContainer.java:1112)
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:971)
    at java.lang.Thread.run(Thread.java:722)
Nov 13, 2012 7:23:37 PM org.apache.catalina.loader.WebappClassLoader loadClass
INFO: Illegal access: this web application instance has been stopped already.  Could not load org.apache.log4j.spi.VectorWriter.  The eventual following stack trace is ca
used by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.
java.lang.IllegalStateException
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1273)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)
    at org.apache.log4j.spi.LoggingEvent.<init>(LoggingEvent.java:154)
    at org.apache.log4j.Category.forcedLog(Category.java:388)
    at org.apache.log4j.Category.log(Category.java:853)
    at org.apache.commons.logging.impl.Log4JLogger.warn(Log4JLogger.java:234)
    at org.springframework.jms.listener.DefaultMessageListenerContainer.handleListenerSetupFailure(DefaultMessageListenerContainer.java:831)
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:981)
    at java.lang.Thread.run(Thread.java:722)

你们有什么想法吗?在关闭Tomcat之前,是否需要关闭或销毁Spring上下文?

感谢您的帮助

谢谢, Keth

1 个答案:

答案 0 :(得分:0)

好吧,看起来你是对的:

  

在关闭Tomcat之前,我是否需要关闭或销毁Spring上下文?

从Spring JSM源代码看,你的Tomcat早先关闭了它的 log4j.LogManager ,而不是Spring停止它的上下文。