我有一个 Tomcat 不会部署的 WAR,虽然它通常会给出它为什么不会部署应用程序的原因或一些指示,但 Tomcat 的 catalina 日志输出只是说明:
严重:上下文 [/appmon-qa] 启动因先前的错误而失败
这是web.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<web-app
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<!-- The display name of this web application -->
<display-name>AppMonitor</display-name>
<listener>
<listener-class>
com.me.myorg.appmon.AppMonitor
</listener-class>
</listener>
</web-app>
该课程中的重要内容AppMonitor
:
public class AppMonitor implements ServletContextListener {
@Override
public void contextDestroyed(ServletContextEvent event) {
return;
}
@Override
public void contextInitialized(ServletContextEvent event) {
try {
// Guts of my monitor app
} catch(Exception exc) {
System.out.println("Something bad happened!\n" + exc.getMessage());
}
}
}
以及非常模糊/不具描述性的日志输出:
INFO: Deploying web application archive appmon-qa.war
Jun 8, 2012 9:45:30 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error listenerStart
Jun 8, 2012 9:45:31 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/appmon-qa] startup failed due to previous errors
Jun 8, 2012 9:45:31 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory docs
Jun 8, 2012 9:45:31 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory examples
Jun 8, 2012 9:45:32 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory host-manager
Jun 8, 2012 9:45:32 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory manager
Jun 8, 2012 9:45:32 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory ROOT
Jun 8, 2012 9:45:32 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Jun 8, 2012 9:45:32 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Jun 8, 2012 9:45:32 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-nio-8010"]
Jun 8, 2012 9:45:32 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 2875 ms
我取消了这个 WAR 并部署了另一个我知道工作正常的 Tomcat 7.0.19 启动它没有任何问题,所以我知道它不是 Tomcat/配置问题。这显然是我的 WAR 的问题。目录结构如下:
appmon-qa.war/
META-INF/
MANIFEST.MF
WEB-INF/
classes/
All of my binaries
lib/
All JAR dependencies
web.xml
如果我的 (super-simple) 有问题web.xml
,Tomcat应该在日志输出中抱怨。如果我没问题,但是在我的方法web.xml/ServletContextListener
中抛出了异常,则该块会将消息打印到控制台-但这没有发生。contextInitialized
catch
关于什么可能是潜在问题或我必须开始诊断这个问题的任何想法?提前致谢!