[Solved] java.lang.ClassNotFoundException: org.Springframework.Web.Context.ContextLoaderListener in Java and Spring

Problem : You are getting java.lang.ClassNotFoundException : org.Springframework.Web.
Context.ContextLoaderListener in your Spring-based Java Web application.
Cause: This error comes when you are using the Spring MVC framework in your Java Web application and configured org.springframework.web.context.ContextLoaderListener as a listener in your deployment descriptor also known as web.xml, but the JAR which contains this class is not available in the web application's CLASSPATH.

This is a very important class in the Spring MVC framework, as it is used to load your spring configuration files like applicatoin-Context.xml and others, defined in the context-param element of web.xml of your Java spring web application, as shown below :


Btw, if you are new to Spring core and Spring MVC then I also suggest you first go through a comprehensive Spring course like Spring Framework 5: Beginner to Guru course on Udemy. It's one of the most up-to-date courses to learn in Spring and covers Spring 5.0 and Reactive Programming as well. It's also very affordable and you can buy in just $9.9 on several Udemy sales.

What causes java.lang.ClassNotFoundException: org.Springframework.Web.Context.ContextLoaderListener?

Like any other ClassNotFoundException error, you first need to find out the JAR file on which this class is bundled and then add that JAR into the appropriate place, like the WEB-INF/lib folder of your web application.

So that the web application class loader like org.apache.catalina.loader.WebappClassLoader can see this JAR file. You can see in below stack trace below that it's the WebappClassLoader that failed to load this class :

SEVERE: Error configuring application listener of class 
java.lang.ClassNotFoundException: org.springframework.web.context
    at org.apache.catalina.loader.WebappClassLoader
    at org.apache.catalina.loader.WebappClassLoader
    at org.apache.catalina.core.DefaultInstanceManager
    at org.apache.catalina.core.DefaultInstanceManager
    at org.apache.catalina.core.DefaultInstanceManager
    at org.apache.catalina.core.StandardContext.listenerStart(
    at org.apache.catalina.core.StandardContext$1.call(
    at org.apache.catalina.core.StandardContext$1.call(
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(
    at java.lang.Thread.run(Thread.java:662)

2. How to solve java.lang.ClassNotFoundException: org.Springframework.Web.Context.ContextLoaderListener in Java 

It appears that the spring context loader listener class i.e. org.springframework.web.context.ContextLoaderListener  is moved to spring-web.jar since Spring 3.0. which means you should do the following to fix java.lang.ClassNotFoundException : org.Springframework.Web.Context.ContextLoaderListener error :

1. If you are using Spring version 3.0 then add spring-web.jar into CLASSPATH, I mean, just put it inside the WEB-INF/lib folder.

2. If you are running in Spring 2.0 or lower version then just add spring.jar into your application's CLASSPATH, the same just put it inside WEB-INF/lib directory.

3. If spring.jar or spring-web.jar is already in CLASSPATH then your problem is not due to JAR but due to a wrongly configured classpath. See my post on how to deal with ClassNotFoundException to troubleshoot further.

4. If you are using Maven then add the following dependency in your pom.xml file :

5. If you are getting java.lang.ClassNotFoundException : org.Springframework.Web.Context.ContextLoaderListener error In Eclipse and Tomcat, then you can also try the following steps to make sure maven dependencies are in CLASSPATH and visible to Tomcat's web application class loader. All you need to do is add maven dependencies into your eclipse project's web deployment assembly.
  • Select Project, Right-click, and choose Properties.
  • Choose the "Deployment Assembly".
  • Click the "Add..." button on the right side.
  • Choose "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 will see maven dependencies added to the web deployment assembly definition by now.

6. If you are getting java.lang.ClassNotFoundException : org.Springframework.Web.Context.ContextLoaderListener error in previously working project and you are sure that you not done anything which causes this error then you can try "Clean Tomcat Work Directory" or simply "Clean..". This is supposed to discard all published states and republish from scratch.

java.lang.ClassNotFoundException:org.Springframework.Web.Context.ContextLoaderListener [Solution]

That's all about how to solve java.lang.ClassNotFoundException : org.Springframework.Web.Context.ContextLoaderListener error in Spring-based Java web application. Mostly it's the case of missing the spring-web.jar file as hardly anyone is running with spring 2.0 now, but it's good to remember that you need to add spring.jar into the classpath for the older spring version and spring-web.jar for the newer spring version, starting from Spring 3.0.

Further Learning
Spring MVC books and resources
Spring Web Application Developer Certification

Thanks for reading this article so far. If you like this interview question then please share it with your friends and colleagues. If you have any questions or suggestions then please drop a comment and I'll try to find an answer for you.

Other common ClassNotFoundExceptions that comes in Java programs :
  • General Guide to solve java.lang.ClassNotFoundException in Java [guide]
  • How to solve java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver in Java? [solution]
  • How to solve java.lang.ClassNotFoundException:org.Springframework.Web.Context.ContextLoaderListener [solution]
  • How to solve java.lang.ClassNotFoundException: com.mysql.jdbc.Driver in Java MySQL? [solution]
  • java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory? [solution]
  • How to connect to MySQL database from Java Program [steps]
  • How to fix java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver in Java? [solution]
  • How to fix java.lang.ClassNotFoundException: org.postgresql.Driver error in Java? [solution]

P. S. - If you want to learn Spring Framework from scratch, check out John Thomson's Spring Framework 5: Beginner to Guru course on Udemy. It's one of the most up-to-date courses to learn in Spring and covers Spring 5.0 and Reactive Programming as well. It's also very affordable and you can buy in just $9.9 on several Udemy sales.


  1. i have tried all the above steps but it doesn't works for me

  2. i have tried all the above steps but it doesn't works for me

  3. i have tried all the above steps but it doesn't works for me

  4. i have tried all the above steps but it doesn't works for me

    1. what is the error you are getting? what have you been tried?

  5. Thanks a lot for this blog. Adding spring-web dependency to pom.xml solved my problem.


Feel free to comment, ask questions if you have any doubt.