Tomcat Spring Error with ContextLoaderListener: NoClassDefFoundError: org/apache/commons/logging/LogFactory

Today I going back to an old web application that contained a simple servlet.  I wanted to quickly add Spring to the project.  Since the project was not making use of Maven, I just put the necessary org.springframework.<module>-3.1.0.RELEASE.jar files in my WEB-INF/lib directory.

I then repackaged my project (created the WAR) and started Apache Tomcat (6.0.35).  I received this error:

Feb 16, 2012 11:10:03 AM org.apache.catalina.core.StandardContext listenerStop
SEVERE: Exception sending context destroyed event to listener instance of class org.springframework.web.context.ContextLoaderListener
java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
 at org.springframework.web.context.ContextCleanupListener.<clinit>(
 at org.springframework.web.context.ContextLoaderListener.contextDestroyed(
 at org.apache.catalina.core.StandardContext.listenerStop(
 at org.apache.catalina.core.StandardContext.stop(
 at org.apache.catalina.core.StandardContext.start(
 at org.apache.catalina.core.ContainerBase.start(
 at org.apache.catalina.core.StandardHost.start(
 at org.apache.catalina.core.ContainerBase.start(
 at org.apache.catalina.core.StandardEngine.start(
 at org.apache.catalina.core.StandardService.start(
 at org.apache.catalina.core.StandardServer.start(
 at org.apache.catalina.startup.Catalina.start(
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(
 at java.lang.reflect.Method.invoke(
 at org.apache.catalina.startup.Bootstrap.start(
 at org.apache.catalina.startup.Bootstrap.main(
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
 at org.apache.catalina.loader.WebappClassLoader.loadClass(
 at org.apache.catalina.loader.WebappClassLoader.loadClass(
 ... 18 more

After some research, I found that Spring has an external logging dependency (discussed in the Spring Reference Manual).  To fix the error, I just downloaded commons-logging.jar and added it to my WEB-INF/lib directory.  Repackaged my project and restarted Tomcat.

No more error!  (And probably time to add Maven to the project too.)


About stevewall123

I am a Lead Software Engineer in Minneapolis working for Thomson Reuters. I am currently working on projects using Java, JavaScript, Spring, Elasticsearch, Hazelcast, Liquibase and Tomcat. Previously, I used C#, GWT, Grails, Groovy, JMS and JBoss Drools Guvnor. In the past I have worked on projects using J2EE, Swing, Webwork, Hibernate, Spring, Spring-WS, JMS, JUnit and Ant.
This entry was posted in Spring, Tomcat and tagged , . Bookmark the permalink.

2 Responses to Tomcat Spring Error with ContextLoaderListener: NoClassDefFoundError: org/apache/commons/logging/LogFactory

  1. Awani says:

    Hi. i m also facing the same error i.e. SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘’: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/apache/http/client/ClientProtocolException
    and i do have commons-logging.jar in my WEB-INF/lib directory. Can plz suggest me anything to get it work.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s