How to solve ‘Error listenerStart’ Error with Spring, Log4j and Tomcat

Working with Spring, Log4j and Tomcat, you may have faced the following error, which prevents your web application to start :

Logs in french :
org.apache.catalina.core.StandardContext start GRAVE: Error listenerStart
org.apache.catalina.core.StandardContext start GRAVE: Erreur de démarrage du contexte [/mywebapp] suite aux erreurs précédentes

Logs in english :
org.apache.catalina.core.StandardContext start SEVERE: Error listenerStart
org.apache.catalina.core.StandardContext start SEVERE: Context [/mywebapp] startup failed due to previous errors

This error seems to come without any additional logs. Webapp startup is interrupted but you can start the application from the tomcat manager successfully.

The explaination for our case are :

  • We are using 2 context listeners : org.springframework.web.util.Log4jConfigListener and org.springframework.web.context.ContextLoaderListener.
  • Log4jConfigListener automatically sets a SYSTEM property : webapp.root to share the application context
  • On Tomcat, system properties are system-wide, thus are shared between applications
  • If 2 applications are installed, the webapp.root value is invalid for the second one, causing the exception

Solution : define a unique webAppRootKey value for each application.

<context-param>
<param-name>webAppRootKey</param-name>
<param-value>app1</param-value>
</context-param>

See :
http://static.springsource.org/spring/docs/2.0.8/api/org/springframework/web/util/WebAppRootListener.html for additional information.

Note : Resin does not have this issue because it does not share system properties between webapps.


  • http://blog.richeton.com/ Nicolas Richeton

    Lost some time on this. Not easy to find out why an application does not start automatically but can still start from Tomcat manager :-)

  • Philippe Deoliveira

    Excellent tip ! bookmarked :-)

  • http://blog.richeton.com/ Nicolas Richeton

    Lost some time on this. Not easy to find out why an application does not start automatically but can still start from Tomcat manager :-)

  • Abhijeet

    Thanks for this tip, I wasted 3 hours wondering why my application won’t deploy.. Very useful post.

  • Thomas Berg

    Great tip Nicolas!

    Have had this problem from time to time in various environments but never knew what to to about it.

    Merci!

  • lzap

    Nice catch but this is more generic error. Basically it appears every time you run into problems in filter initialization.

  • Cwhittl

    Thanks Nicolas! Prod Problem Solved