1

我已经浏览了类似的问题,但没有提出任何问题,所以就这样吧。我安装了 Tomcat 7,然后用 maven 编译了 PetClinic 应用程序。我成功地将它部署到Tomcat。我已经取消部署并重新编译了war文件并部署了它,现在它抛出错误FAIL - 无法启动上下文路径/petclinic的应用程序。这是日志文件的前几行。请指教。谢谢。

    Sep 23, 2012 2:21:10 PM org.apache.catalina.core.ApplicationContext log
INFO: Closing Spring root WebApplicationContext
Sep 23, 2012 2:21:10 PM org.apache.catalina.core.StandardContext listenerStop
SEVERE: Exception sending context destroyed event to listener instance of class org.springframework.web.context.ContextLoaderListener
java.lang.NoClassDefFoundError: org/apache/log4j/LogManager$PrivateManager
    at org.apache.log4j.LogManager.getLogger(LogManager.java:34)
    at org.slf4j.impl.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:73)
    at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:209)
    at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:155)
    at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:131)
    at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:272)
at org.springframework.web.context.ContextCleanupListener.<clinit>(ContextCleanupListener.java:43)
at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:80)
at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4831)
at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5478)
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:160)
at org.apache.catalina.manager.ManagerServlet.start(ManagerServlet.java:1255)
at org.apache.catalina.manager.HTMLManagerServlet.start(HTMLManagerServlet.java:714)
at org.apache.catalina.manager.HTMLManagerServlet.doPost(HTMLManagerServlet.java:219)
4

1 回答 1

0

问题在这里:

SEVERE: Exception sending context destroyed event to listener instance of class org.springframework.web.context.ContextLoaderListener
java.lang.NoClassDefFoundError: org/apache/log4j/LogManager$PrivateManager
    at org.apache.log4j.LogManager.getLogger(LogManager.java:34)
    at org.slf4j.impl.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:73)
    at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:209)
    at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:155)
    at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:131)

问:您使用的是 log4j(这是我推荐的)还是 slf4j?

建议:

1) 确保相关的 .jar 文件(哎呀——为什么不同时包含log4j和 slf4j .jars)在您的 WAR 的 WEB-INF/lib 文件夹中。

2) 确保您的 Tomcat 环境中只有一个log4j 版本(您可能有两个相互冲突的 .jar 版本)。

于 2012-09-23T21:09:08.227 回答