And the common error message is, your server can not find this Spring ContextLoaderListener class during the server start up.

SEVERE:Error configuring application listener of class
org.springframework.web.context.ContextLoaderListener java.lang.ClassNotFoundException:
org.springframework.web.context.ContextLoaderListener
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1516)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1361)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3915)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4467)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
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:519)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
at sun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)

Solution

This is always happened in deployment and debugging environment.

1.Deployment environment

In deployment environment, just make sure your server classpath has included the Spring jar library (e.g spring-2.5.6.jar).

For Spring3, ContextLoaderListener is moved to spring-web.jar, you can get the library from Maven central repository.

2.Debugging environment

In debugging environment, the steps may vary from different IDE, but the solution is same. In Eclipse, developers usually will create a tomcat, jboss…whatever application server for debugging, just make sure the correct Spring jars are included.

SEVERE: Error configuring application listener of class org.springframework.web.context.ContextLoaderListener java.lang.NoClassDefFoundError: org/springframework/context/ApplicationContextException at java.lang.Class.getDeclaredConstructors0(Native Method) at java.lang.Class.privateGetDeclaredConstructors(Class.java:2483) at java.lang.Class.getConstructor0(Class.java:2793) at java.lang.Class.newInstance(Class.java:345) at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:127) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4660) at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5226) at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5221) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) at java.util.concurrent.FutureTask.run(FutureTask.java:166) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:724) Caused by: java.lang.ClassNotFoundException: org.springframework.context.ApplicationContextException

I’m not using Eclipse but a CLI Maven project. Spring version is 3.1.4.RELEASE. So, I tried to copy the proper spring-web and its dependencies to JBoss lib without a success. Do you have any suggestion about this scenario? Regards.

In the properties/Web Deployment Assembly screen it should show up as: Source – Deploy Path Maven Dependencies – WEB-INF/lib

Salim.s

THx A lot!!!!

Marina

Very thanks!!! you save me

Venkat

yes must do this thank for remembering. some times it automatically add mavendependecies if not we have to add thank u

Mohit Khanna

I have tried adding servlet-api.jar but then i am getting the below error:

SEVERE: Error configuring application listener of class org.springframework.web.context.ContextLoaderListener java.lang.ExceptionInInitializerError at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at java.lang.Class.newInstance0(Unknown Source) at java.lang.Class.newInstance(Unknown Source) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3787) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4342) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) at org.apache.catalina.core.StandardHost.start(StandardHost.java:719) 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:578) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413) Caused by: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: java.lang.NullPointerException (Caused by java.lang.NullPointerException) (Caused by org.apache.commons.logging.LogConfigurationException: java.lang.NullPointerException (Caused by java.lang.NullPointerException)) at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:543) at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:235) at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:209) at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:351) at org.springframework.web.context.ContextLoader.(ContextLoader.java:144) … 21 more Caused by: org.apache.commons.logging.LogConfigurationException: java.lang.NullPointerException (Caused by java.lang.NullPointerException) at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:397) at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:529) … 25 more Caused by: java.lang.NullPointerException at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:374) … 26 more

I too facing the same error.with the same configuration as you.If U find the solution plz intimate me

George

This error can occur for a number of reasons for example you are running from eclipse Tomcat a spring 3.05 Release web application and java 1.X (ie 1.6)is set in Project build path (1.6), in project compiler (1.6) but not in maven!!! (maven works with default 1.5), so eclipse tries to bind your project with a default 1.5 old java and your project fails with org.springframework.web.context.ContextLoaderListen ..

I run into similar problem, which is why I come to your blog now. You are very correct that the problem is deployment. Thanks a lot!

BC

rguenther

i resolved the problem with removing all libraries from WEB-INF/lib as they are already loaded by tomcat and included log4j properties in the projects build path. after importing one log4j.properties into the project the contextlistener runs proper.

sikinder

Hi Yang,

Thanks for such simple and wonderful articles. I am getting the same error using spring 3.1.0. As Spring.jar is not included in this version, please tell me how to fix the problem without using maven and ant.

I have tried all the options mentioned here( adding libraries to tomcat folder).

Thanks. Sikinder.

http://www.mkyong.com mkyong

Maven or Ant is doing the same thing, copy spring.jar to your project classpath.

http://lucasterdev.altervista.org/wordpress Lucaster

I got the same error, together with several others, during Tomcat startup with a Spring project deployed.

But in my case, the errors were caused by the project facet “Java” being set to 1.5 instead of 1.6

Thanks a lot , i was facing this error from monday and i’ve tried many issus but without result, thank you so much

CRL

Still doesn’t work for me, driving me nuts. WHY is it necessary to find the correct jar (whichever it may be) to enable Tomcat deployment properly??

http://www.mkyong.com mkyong

patient, of course Tomcat need to find correct jar for deployment, do you have problem in production or IDE environment?

Marco

Hi I have the same problem, I created a web project and trying to use Spring Dynamic Modules, I copied the needed library in the lib directory of my project. I am using Eclipse and I try to deploy the project in the tomcat directly from the IDE. The first error was: java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener According to the comments in the thread I added the spring-web.jar and/or the web library of SPring DM to the tomcat library, and the error changed to: java.lang.NoClassDefFoundError: javax/servlet/ServletContextListener but now I amnot able to remove the error neither adding servlet-api.jar nand with javax.servlet…..Can you please help me? Which are the libraries to add? I am using Spring DM 2.0.0.M1, Spring 3.0.0.RC1 e tomcat6 in STS eclipse environment.

Marco

Chirag

Hi,

I am too facing the same problem. Did you found the solution for this?

enigma

I don’t understand this. I created “Dynamic Project” in STS, I added all necessary dependiences (also spring-web 3.0.2.RELEASE) and in Maven Dependiences in my project org.springframework.web.context.ContextLoaderListener exists, so why I need configure in your way?

i configure the spring jar file after that also i get same class not found exeception

http://www.mkyong.com mkyong

Make sure the jar is deployed into correct folder

lakshmanan

sir i am lakshmanan.i am work to java platform.javac compile my coding it is not run it is show class not found or null pointer exception or class loader example for create image button and label and please send sql connect coding wait for your reply by lakshmanan