Sunday, May 02, 2010

How to solve - SEVERE: Error listenerStart


Ever get the SEVERE: Error listenerStart and can't find the error? Logs don't seem to help since this is a container start up problem.

May 3, 2010 3:01:09 PM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jdk1.5.0_07\bin;C:\Program Files\Tomcat\5.5\bin;C:\oracle\ora10_2\BIN
May 3, 2010 3:01:10 PM org.apache.coyote.http11.Http11BaseProtocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
May 3, 2010 3:01:10 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 984 ms
May 3, 2010 3:01:10 PM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
May 3, 2010 3:01:10 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/5.5.26
May 3, 2010 3:01:10 PM org.apache.catalina.core.StandardHost start
INFO: XML validation disabled
log4j:WARN No appenders could be found for logger (org.apache.commons.digester.Digester.sax).
log4j:WARN Please initialize the log4j system properly.
May 3, 2010 3:01:15 PM org.apache.catalina.core.StandardContext start
SEVERE: Error listenerStart
May 3, 2010 3:01:15 PM org.apache.catalina.core.StandardContext start
SEVERE: Context [/CameraProject] startup failed due to previous errors
log4j:ERROR LogMananger.repositorySelector was null likely due to error in class reloading, using NOPLoggerRepository.

May 3, 2010 3:01:15 PM org.apache.coyote.http11.Http11BaseProtocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
May 3, 2010 3:01:16 PM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
May 3, 2010 3:01:16 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/63  config=null
May 3, 2010 3:01:16 PM org.apache.catalina.storeconfig.StoreLoader load
INFO: Find registry server-registry.xml at classpath resource
May 3, 2010 3:01:16 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 6391 ms

Start Tomcat
=========
I'm using tomcat - and whilst I understand Jetty is meant to be good for development, it doesn't seem to yet support eclipse 3.2. You probably have a script to start and restart tomcat or using a plugin to restart it. I'm using sysdeo (http://www.eclipseplugincentral.com/...k-cid-120.html) which seemed to me to be the most common. With the sysdeo plug in I can start my tomcat in eclipse which can link in to the debugger. In this case I have used MyEclipse to reproduce the error.

Attach the source
==============
in your build path (project properties, java build path) select the libraries tab and the spring jar. Expand the + and click on source attachment, and edit the path to be the spring source 'src' directory. I manually downloaded spring 3.0 release with the sources and pointed to that jar file : http://www.springsource.com/download/community


Set Breakpoint in ContextLoaderListener
=========================
In the spring jar on the build path, find org.springframework.web.context and the ContextLoaderListener class. Set a breakpoint at line which will read this.contextLoader.initWebApplicationContext(event .getServletContext()); This will be around line 47 (Spring 3.0)


find the error!
==========
Now when you start tomcat from within an eclipe plugin it will stop at the above. Choose to 'step return' once and then wait for the container to load everything up and find an error. If there is an error you will now be at standardcontext.listenerstart and you can now look at the error in the variable window under 't'. There are 'cause' error, make sure you take a look at them all since some can be wrapped/hidden. If you're using hibernate, I find that this does show the hbm mapping file problems, but the actual bean which causes the error can be wrong - it seems to just take the first bean in its list!

 

StandardContext

In my case the error was :-

java.io.FileNotFoundException: class path resource [application.properties] cannot be opened because it does not exist

2 comments:

  1. Thank you, you saved me a lot of time.
    I had to go for jetty every time I wanted to find errors.

    ReplyDelete
  2. Here's an easier way

    http://blog.jteam.nl/2011/03/18/debugging-the-dreaded-severe-error-listenerstart-and-severe-error-filterstart-tomcat-error-messages/

    ReplyDelete

Thank you for your feedback