ClassNotFoundException : org.springframework.web.context.ContextLoaderListener

Problem

The ContextLoaderListener is used to integrate Spring with other web application.


  <!-- file : web.xml --> 
 <context-param>
	<param-name>contextConfigLocation</param-name>
	<param-value>/WEB-INF/Spring/applicationContext.xml</param-value>
  </context-param>

  <listener>
    <listener-class>
          org.springframework.web.context.ContextLoaderListener
    </listener-class>
  </listener>

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(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: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.


	<dependency>
		<groupId>org.springframework</groupId>
		<artifactId>spring-web</artifactId>
		<version>3.0.5.RELEASE</version>
	</dependency>

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.

1. Double click on your debugging server
2. Click on the “Open launch configuration” to access the server environment

3. Click on the classpath tab
4. Include the Spring jar file here , it may also required common log jar due to Spring dependency.

5. Done, run your application again.

75 comments on “ClassNotFoundException : org.springframework.web.context.ContextLoaderListener

  1. Awesome article!

    I am using Gradle. Which is the process?

    Reply
  2. Without adding the jar manually in class path, is there any solution ? Thanks

    Reply
  3. I had the same problem with Inteligi IDEA.
    What should you do to solve this problem when you are usin IDEA
    1) Click File -> Project Structure
    2) Click Artifacts -> select your artifact
    3) In right column in “Available Elements” column double-click all libraries
    4) Click “Apply” -> Click “??”
    Done! Now when maven will build war file, it will include libraris frop step 3 to your war file in lib folder

    Reply
    1. just saved my life thanks, your solution worked for me.

      Reply
  4. Maybe this will help someone. This entry in the .classpath file was messed up. The 2nd attribute was gone from mine:

    Reply
  5. On a Struts2 Spring 4 Integration project adding the spring-web.jar causes Tomcat Catalina sartup error. I do see the dependency show spring-web but in the launch classpath its spring.jar. I dont see a spring jar in my maven repo, am I missing something ? or What jar file I have to load for Spring4?

    Reply
  6. Hi,i am getting the same exception even followed above steps.This is my code
    pom.xml:-

    4.0.0
    com
    narayana
    war
    0.0.1-SNAPSHOT
    narayana Maven Webapp
    http://maven.apache.org

    3.2.6.RELEASE

    org.hibernate
    hibernate-annotations
    3.3.1.GA

    com.oracle
    ojdbc14
    10.2.0.2.0

    asm
    asm
    1.5.3

    junit
    junit
    3.8.1
    test

    javax.servlet
    servlet-api
    2.5

    org.springframework
    spring-orm
    ${spring.version}

    org.springframework
    spring-core
    ${spring.version}

    org.springframework
    spring-web
    ${spring.version}

    org.springframework
    spring-context
    ${spring.version}

    org.springframework
    spring-webmvc
    ${spring.version}

    commons-dbcp
    commons-dbcp
    1.2.2

    org.hibernate
    hibernate-core
    3.6.3.Final

    javassist
    javassist
    3.12.1.GA

    org.springframework
    spring-hibernate3
    2.0.8

    com.eshop

    web.xml:-

    Spring3MVC

    Login.jsp

    spring

    org.springframework.web.servlet.DispatcherServlet

    1

    spring
    *.html

    contextConfigLocation
    /WEB-INF/spring-servlet.xml

    org.springframework.web.context.ContextLoaderListener

    spring-servlet.xml:-

    com.eshop.EShopUser

    org.hibernate.dialect.OracleDialect
    thread
    true

    The remaining code consists My jsp pages,Controller classes,service classes and DAOs.

    But when i run this it shows the below Exception.If you want i will send full code.Please give suggestions how to solve this.

    Jul 14, 2015 6:30:46 PM org.apache.catalina.core.AprLifecycleListener init
    INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:Program FilesJavajdk1.7.0_79bin;C:WindowsSunJavabin;C:Windowssystem32;C:Windows;C:/Program Files/Java/jdk1.7.0_79/bin/../jre/bin/server;C:/Program Files/Java/jdk1.7.0_79/bin/../jre/bin;C:/Program Files/Java/jdk1.7.0_79/bin/../jre/lib/amd64;C:Program FilesJavajdk1.7.0_79bin;D:apache-maven-3.1.1bin;C:Program FilesJavajdk1.7.0_79bin;C:UsersNARAYANADesktopEclipse FolderNew foldereclipse;;.
    Jul 14, 2015 6:30:47 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
    WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property ‘source’ to ‘org.eclipse.jst.j2ee.server:com.eshop’ did not find a matching property.
    Jul 14, 2015 6:30:47 PM org.apache.coyote.AbstractProtocol init
    INFO: Initializing ProtocolHandler [“http-bio-2014”]
    Jul 14, 2015 6:30:47 PM org.apache.coyote.AbstractProtocol init
    INFO: Initializing ProtocolHandler [“ajp-bio-8009”]
    Jul 14, 2015 6:30:47 PM org.apache.catalina.startup.Catalina load
    INFO: Initialization processed in 933 ms
    Jul 14, 2015 6:30:47 PM org.apache.catalina.core.StandardService startInternal
    INFO: Starting service Catalina
    Jul 14, 2015 6:30:47 PM org.apache.catalina.core.StandardEngine startInternal
    INFO: Starting Servlet Engine: Apache Tomcat/7.0.53
    Jul 14, 2015 6:30:48 PM org.apache.catalina.util.SessionIdGenerator createSecureRandom
    INFO: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [173] milliseconds.
    Jul 14, 2015 6:30:48 PM org.apache.catalina.core.StandardContext listenerStart
    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:1720)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)
    at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:529)
    at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:511)
    at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:139)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4888)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5467)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    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:745)

    Jul 14, 2015 6:30:48 PM org.apache.catalina.core.StandardContext listenerStart
    SEVERE: Skipped installing application listeners due to previous error(s)
    Jul 14, 2015 6:30:48 PM org.apache.catalina.core.StandardContext startInternal
    SEVERE: Error listenerStart
    Jul 14, 2015 6:30:48 PM org.apache.catalina.core.StandardContext startInternal
    SEVERE: Context [/com.eshop] startup failed due to previous errors
    Jul 14, 2015 6:30:48 PM org.apache.coyote.AbstractProtocol start
    INFO: Starting ProtocolHandler [“http-bio-2014”]
    Jul 14, 2015 6:30:48 PM org.apache.coyote.AbstractProtocol start
    INFO: Starting ProtocolHandler [“ajp-bio-8009”]
    Jul 14, 2015 6:30:48 PM org.apache.catalina.startup.Catalina start
    INFO: Server startup in 1068 ms

    Reply
  7. I had a similar problem when running a spring web application in an Eclipse managed tomcat. I solved this problem by adding maven dependencies in the project’s web deployment assembly.

    Open the project’s properties (e.g., right-click on the project’s name in the project explorer and select “Properties”).

    Select “Deployment Assembly”.

    Click the “Add…” button on the right margin.

    Select “Java Build Path Entries” from the menu of Directive Type and click “Next”.

    Select “Maven Dependencies” from the Java Build Path Entries menu and click “Finish”.

    You should see “Maven Dependencies” added to the Web Deployment Assembly definition.

    Reply
  8. I had the same error I resolved it like that (I use eclipse) Right click on your project –> “Propeties” -> Deployment Assembly -> Add -> Java Build Path Entries -> Maven Dependencies (I selected them all) -> Finish

    Reply
    1. This indeed solved my issue as well. This is a way better solution than provided in this article. Now you don’t have to add dependencies to Tomcat anymore and are all dependencies still managed by Maven.

      Reply
    2. Good suggestion. Worked for me as well after facing the same issue.

      Reply
  9. Hi, I am also getting this same error
    Exception in thread “main” org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘step1’: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: org/springframework/retry/policy/RetryContextCache

    Not able to fix this. Please can someone help. I tried all above combinations and put spring jar also in the build path.

    Reply
  10. FINALLY! THANK YOU!

    The weird thing is, before starting this tutorial, it was added already. Then, for some reason, in the midst of this tutorial, it decided to remove it, so I didn’t even think to check it again until I came across this and though “what the hell, let’s make sure.”

    Damn you eclipse…

    Reply
  11. 17 Sep, 2013 2:59:35 PM org.apache.catalina.core.AprLifecycleListener init
    INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre1.6.0_03\bin;.;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jre1.6.0_03/bin/client;C:/Program Files/Java/jre1.6.0_03/bin;C:/Program Files/Java/jre1.6.0_03/lib/i386;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Windows Live\Shared;E:\java\eclipse-jee-juno-win32\eclipse;
    17 Sep, 2013 2:59:36 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
    WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property ‘source’ to ‘org.eclipse.jst.jee.server:swytchboard’ did not find a matching property.
    17 Sep, 2013 2:59:37 PM org.apache.coyote.AbstractProtocol init
    INFO: Initializing ProtocolHandler [“http-bio-8080”]
    17 Sep, 2013 2:59:37 PM org.apache.coyote.AbstractProtocol init
    INFO: Initializing ProtocolHandler [“ajp-bio-8009”]
    17 Sep, 2013 2:59:37 PM org.apache.catalina.startup.Catalina load
    INFO: Initialization processed in 2318 ms
    17 Sep, 2013 2:59:37 PM org.apache.catalina.core.StandardService startInternal
    INFO: Starting service Catalina
    17 Sep, 2013 2:59:37 PM org.apache.catalina.core.StandardEngine startInternal
    INFO: Starting Servlet Engine: Apache Tomcat/7.0.34
    17 Sep, 2013 2:59:38 PM org.apache.catalina.loader.WebappClassLoader validateJarFile
    INFO: validateJarFile(C:\Users\rani\workspace9.0\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\swytchboard\WEB-INF\lib\servlet-api-2.5.jar) – jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
    17 Sep, 2013 2:59:38 PM org.apache.catalina.core.StandardContext listenerStart
    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:1714)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
    at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:532)
    at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:514)
    at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:133)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4727)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5285)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    17 Sep, 2013 2:59:38 PM org.apache.catalina.core.StandardContext listenerStart
    SEVERE: Error configuring application listener of class com.sun.xml.ws.transport.http.servlet.WSServletContextListener
    java.lang.ClassNotFoundException: com.sun.xml.ws.transport.http.servlet.WSServletContextListener
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
    at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:532)
    at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:514)
    at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:133)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4727)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5285)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    17 Sep, 2013 2:59:38 PM org.apache.catalina.core.StandardContext listenerStart
    SEVERE: Skipped installing application listeners due to previous error(s)
    17 Sep, 2013 2:59:38 PM org.apache.catalina.core.StandardContext startInternal
    SEVERE: Error listenerStart
    17 Sep, 2013 2:59:41 PM org.apache.catalina.util.SessionIdGenerator createSecureRandom
    INFO: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [2,329] milliseconds.
    17 Sep, 2013 2:59:41 PM org.apache.catalina.core.StandardContext startInternal
    SEVERE: Context [] startup failed due to previous errors
    17 Sep, 2013 2:59:41 PM org.apache.coyote.AbstractProtocol start
    INFO: Starting ProtocolHandler [“http-bio-8080”]
    17 Sep, 2013 2:59:41 PM org.apache.coyote.AbstractProtocol start
    INFO: Starting ProtocolHandler [“ajp-bio-8009”]
    17 Sep, 2013 2:59:41 PM org.apache.catalina.startup.Catalina start
    INFO: Server startup in 3822 ms

    Reply
  12. Hi
    I have added spring-web-3.0.3.jar, but now I am getting error :

    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

    Reply
    1. … resolved by adding the artifact below in the [pom.xml] :

      org.springframework
      spring-context
      ${spring.version}

      Reply
  13. Exception in thread “main” org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘step1’: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: org/springframework/retry/policy/RetryContextCache

    i am getting this error while runing test class using . main method ..

    Reply
  14. struggled with this all day … turns out that i was missing the spring-context-support jar.
    i added it into my pom and everything is working now.
    thanks

    org.springframework
    spring-context-support
    ${org.springframework-version}

    error log:

    com.ibm.ws.webcontainer.annotation.WASAnnotationHelper collectClasses unable to instantiate class
    java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
    SRVE0293E: [Servlet Error]-[Failed to load listener: org.springframework.web.context.ContextLoaderListener]:
    java.lang.ClassNotFoundException: class java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
    loadLifecycleListeners SRVE0279E: Error occured while processing global listeners for the application {0}: {1}
    java.lang.NullPointerException
    at com.ibm.ws.webcontainer.annotation.WASAnnotationHelper.inject(WASAnnotationHelper.java:266)

    Reply
  15. 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.

    Reply
  16. After a long search this is what solved it for me:

    go to project properties -> Deployment Assembley, click Add… , select Java Build Path Entries and add the Maven Dependencies to the Web Deployment Assembly.

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

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

      Reply
  17. 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

    Not able to recognize where i am doing wrong….

    Reply
  18. I have the same error:

    493 ERROR [ContainerBase] Error configuring application listener of class org.springframework.web.context.ContextLoaderListener
    java.lang.NoClassDefFoundError: javax/servlet/ServletContextListener
    

    I use Eclipse Juno, JBoss 4.2

    I added the spring-2.5.6.jar as you mentioned above.

    Still the same error.

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

      Reply
  19. 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 ..

    http://sosiouxme.wordpress.com/2012/05/21/470/

    You have to set the java version in maven as well:

    org.apache.maven.plugins
    maven-compiler-plugin
    2.1

    1.6
    1.6

    Reply
  20. hi,

    org.springframework.web.context.ContextLoaderListener

    org.springframework.web.context.request.RequestContextListener

    is not working in my jbossas 7server.. but it is not working.. please reply ASAP..

    Reply
  21. I updated my sts from 2.5 to 2.9 and not working, always show this error. I did all what do you say but it is not working 🙁

    Reply
  22. INF
    Iam facing this error while running the application Please help me!!
    O: Starting service Catalina
    Jul 12, 2012 5:37:04 PM org.apache.catalina.core.StandardEngine start
    INFO: Starting Servlet Engine: Apache Tomcat/6.0.18
    java.lang.reflect.InvocationTargetException
    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: java.lang.NoClassDefFoundError: javax/servlet/http/HttpServlet

    Reply
  23. This is how I fixed this issue:

    Create a “lib” folder inside the “WEB-INF” folder and then copy all the spring jars and commons-logging jar (and any other dependency jar) in that newly created lib folder.

    Reply
  24. Hello,

    I’m creating a sample spring application but even i’m not able to start the server using eclipse IDE. This is the error

    GRAVE: Erreur lors de la configuration de la classe d’écoute de l’application (application listener) org.springframework.web.context.ContextLoaderListener
    java.lang.NoClassDefFoundError: javax/servlet/ServletContextListener
    at java.lang.ClassLoader.findBootstrapClass(Native Method)

    I have loaded all the jar as a user libraries. I have tried your Debugging environment but it’s showing same error.

    Please give your solution on this.

    Thanks in advance.

    Reply
  25. Hi Yang,

    I’m creating a sample spring application but even i’m not able to start the server using eclipse IDE. This is the error
    ClassNotFoundException : org.springframework.web.context.ContextLoaderListener

    I have loaded all the jar as a user libraries. I have tried your Debugging environment but it’s showing same error.

    Please give ur suggestion/solution on this.

    Thanks in advance.

    Reply
  26. I am getting same kind of error in RAD, websphere environment how to fix this, can you please help me ??

    com.ibm.ws.webcontainer.webapp.WebApp logError SRVE0293E: 
    [Servlet Error]-[Failed to load listener: org.springframework.web.context.ContextLoaderListener]: 
    java.lang.ClassNotFoundException: 
    class java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
    
    Reply
      1. Hi mkyong,

        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

        Reply
  27. 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.

    Reply
    1. how to import log4j.properties can u explain more i get this exception

      Reply
  28. 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.

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

      Reply
  29. 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

    Reply
  30. I got an error like this.

    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:1645)

    You can find the solution of this error here
    http://www.mustafakurkcu.com/java/221-javaeemoduledependencies.html

    Reply
  31. The error changes to:

    SEVERE: Error configuring application listener of class org.springframework.web.context.ContextLoaderListener
    java.lang.NoClassDefFoundError: javax/servlet/ServletContextListener
    at java.lang.ClassLoader.findBootstrapClass(Native Method)
    at java.lang.ClassLoader.findBootstrapClass0(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ...
    Mar 16, 2011 12:14:23 PM org.apache.catalina.startup.Catalina start
    INFO: Server startup in 220 ms
    
    Reply
    1. Tomcat, right? Your Tomcat can’t find this class

      java.lang.NoClassDefFoundError: javax/servlet/ServletContextListener

      if not mistake, it should be “servlet-api.jar” in Tomcat, make sure it’s included in your Tomcat classpath.

      Reply
      1. After I add the “servlet-api.jar” I get the below error.

        java.lang.reflect.MalformedParameterizedTypeException
        at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.validateConstructorArguments(ParameterizedTypeImpl.java:60)
        at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.(ParameterizedTypeImpl.java:53)
        at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.make(ParameterizedTypeImpl.java:95)
        at sun.reflect.generics.factory.CoreReflectionFactory.makeParameterizedType(CoreReflectionFactory.java:105)
        at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:140)
        at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49)
        at sun.reflect.generics.repository.ClassRepository.getSuperInterfaces(ClassRepository.java:100)
        at java.lang.Class.getGenericInterfaces(Class.java:814)
        at org.springframework.core.GenericTypeResolver.getTypeVariableMap(GenericTypeResolver.java:161)
        at org.springframework.core.GenericTypeResolver.resolveReturnType(GenericTypeResolver.java:99)
        at org.springframework.beans.GenericTypeAwarePropertyDescriptor.getPropertyType(GenericTypeAwarePropertyDescriptor.java:88)
        at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:138)
        at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:832)
        at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:651)
        at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:78)
        at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:63)
        at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:119)
        at javax.servlet.GenericServlet.init(GenericServlet.java:160)
        at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1213)
        at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1026)
        at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4421)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:4734)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
        at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
        at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
        at org.apache.catalina.core.StandardService.start(StandardService.java:525)
        at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)

        Nov 19, 2013 3:23:05 PM org.apache.catalina.core.StandardContext loadOnStartup
        SEVERE: Servlet /RealEstate threw load() exception
        java.lang.reflect.MalformedParameterizedTypeException
        at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.validateConstructorArguments(ParameterizedTypeImpl.java:60)
        at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.(ParameterizedTypeImpl.java:53)
        at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.make(ParameterizedTypeImpl.java:95)
        at sun.reflect.generics.factory.CoreReflectionFactory.makeParameterizedType(CoreReflectionFactory.java:105)
        at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:140)
        at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49)
        at sun.reflect.generics.repository.ClassRepository.getSuperInterfaces(ClassRepository.java:100)
        at java.lang.Class.getGenericInterfaces(Class.java:814)
        at org.springframework.core.GenericTypeResolver.getTypeVariableMap(GenericTypeResolver.java:161)
        at org.springframework.core.GenericTypeResolver.resolveReturnType(GenericTypeResolver.java:99)
        at org.springframework.beans.GenericTypeAwarePropertyDescriptor.getPropertyType(GenericTypeAwarePropertyDescriptor.java:88)
        at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:138)
        at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:832)
        at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:651)
        at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:78)
        at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:63)
        at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:119)
        at javax.servlet.GenericServlet.init(GenericServlet.java:160)
        at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1213)
        at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1026)
        at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4421)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:4734)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
        at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
        at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
        at org.apache.catalina.core.StandardService.start(StandardService.java:525)
        at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)

        What does this error mean and How do I go about resolving this? Thanks.

        Reply
  32. Copy these 4 jars in tomcats lib dir

    com.springsource.org.apache.commons.digester-1.8.1.jar
    com.springsource.org.apache.commons.collections-3.2.1.jar
    com.springsource.org.apache.commons.beanutils-1.8.0.jar
    com.springsource.org.apache.commons.logging-1.1.1.jar

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

      Reply
  33. 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??

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

      Reply
      1. 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

        Reply
        1. Hi,

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

          Reply
  34. 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?

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

    Reply
      1. 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

        Reply
  36. tomcat is not recogized librarys in folder

    Reply
    1. Go To project properties – > Deployment Assembly Option and add Maven Dependencies from Java Build path entries.

      Reply
      1. Thanks!!!.
        My Fix was: I manually added all the dependencies from Java Build Path Entries.

        the mvn eclipse:eclipse -Dwtpversion=2.0 worked for my first project but when i created again a new project then it won’t work anymore so i tried the above fix.

        Thanks!

        Reply

Leave a Comment

Your email address will not be published. Required fields are marked *