Tomcat错误 - 失败 - 无法启动上下文路径/ petclinic中的应用程序(Tomcat Error - FAIL - Application at context path /petclinic could not be started)

我已经浏览了类似的问题并且没有提出任何问题。 我安装了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)

I have browsed the similar questions and come up with nothing so here goes. I installed Tomcat 7 and then compiled the PetClinic app with maven. I deployed it to Tomcat successfully. I have since undeployed and recompiled the war file and deployed it and now it throws the error FAIL - Application at context path /petclinic could not be started. Here are the first few lines of the log file. Please advise. Thanks.

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)

最满意答案

问题出在这里:

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版本)。

The problem is here:

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)

Q: Are you using log4j (that's what I'd recommend) or slf4j?

SUGGESTIONS:

1) Make sure the relevant .jar files (heck - why not include both log4j and slf4j .jars) are in your WAR's WEB-INF/lib folder.

2) Make sure you have only one version of log4j in your Tomcat environment (it's possible that maybe you might have two, conflicting, versions of the .jar laying around).

更多推荐