Friday, October 14, 2011

Tomcat 6 - SEVERE: Error listenerStart - How to Log the Stacktrace

If you run into the Tomcat 6 error "SEVERE: Error listenerStart", a quick way to get logging to work so you can see the error/exception/stacktrace is to add the following file to a file logging.properties that you should put into webapps/your_webapp_name/WEB-INF/classes (putting it into conf/logging.properties didn't work):

org.apache.catalina.core.ContainerBase.[Catalina].level = FINEST
org.apache.catalina.core.ContainerBase.[Catalina].handlers = java.util.logging.ConsoleHandler

Thanks to Venkatt Guhesan's post for this info.

In our case, the only file in work/Catalina/localhost/your_webapp_name/ was SESSIONS.ser. This seemed to indicate that maybe it was unable to compile something or to load the classes. It turned out to be a missing class/jar.

The resulting stacktrace in my case was similar to:

SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
 at org.springframework.web.context.ContextLoader.(ContextLoader.java:139)
 at org.springframework.web.context.ContextLoaderListener.createContextLoader(ContextLoaderListener.java:57)
 at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:48)
 at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3972)
 at org.apache.catalina.core.StandardContext.start(StandardContext.java:4467)
 at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
 at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
 at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:526)
 at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:905)
 at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:740)
 at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:500)
 at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1277)
 at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:321)
 at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
 at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
 at org.apache.catalina.core.StandardHost.start(StandardHost.java:722)
 at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
 at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
 at org.apache.catalina.core.StandardService.start(StandardService.java:516)
 at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
 at org.apache.catalina.startup.Catalina.start(Catalina.java:593)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
 at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
 at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
 at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1484)
 at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1329)
 ... 27 more
Oct 14, 2011 10:11:30 AM org.apache.catalina.core.StandardContext start
SEVERE: Error listenerStart
Oct 14, 2011 10:11:30 AM org.apache.catalina.core.StandardContext start
SEVERE: Context [/your_webapp_name] startup failed due to previous errors

Of course, your error is probably different.

No comments: