I have a WAR that Tomcat will not deploy, and whereas it normally gives me the reason or some indication as to why it won't deploy the app, Tomcat's catalina log output simply states:
SEVERE: Context [/appmon-qa] startup failed due to previous errors
Here's is the 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>
And the important stuff inside that AppMonitor
class:
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());
}
}
}
And the remarkably vague/undescriptive log output:
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
I undeployed this WAR and deployed another one that I know works fine and Tomcat 7.0.19 launched it without any problems, so I know its not a Tomcat/configuration issue. This is clearly something wrong with my WAR. Directory structure is as follows:
appmon-qa.war/
META-INF/
MANIFEST.MF
WEB-INF/
classes/
All of my binaries
lib/
All JAR dependencies
web.xml
If there was something wrong with my (super-simple) web.xml
, Tomcat should be complaining in the log output. If my web.xml/ServletContextListener
was fine, but something was throwing an exception inside my contextInitialized
method, the catch
block would be printing the message to the console - but that's not happening.
Any ideas as to what could be the underlying problem or what options I have to start diagnosing this? Thanks in advance!
You should call the super class in your methods.
@Override
public void contextInitialized(ServletContextEvent servletContextEvent) {
super.contextInitialized(servletContextEvent);
.... }
and
@Override
public void contextDestroyed(ServletContextEvent servletContextEvent) {
super.contextDestroyed(servletContextEvent);
}
As an extra you could make sure to increase the log level on your tomcat server (maybe integrate log4j) http://tomcat.apache.org/tomcat-7.0-doc/logging.html
Mihai
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With