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

Problem : You are getting java.lang.ClassNotFoundException : org.Springframework.Web.
Context.ContextLoaderListener inward your Spring-based Java Web application.
Cause : This fault comes when y'all are using Spring MVC framework inward your Java Web application together with configured org.springframework.web.context.ContextLoaderListener every bit a listener inward your deployment descriptor likewise known every bit web.xml, but the JAR which contains this cast is non available inward spider web application's CLASSPATH. This is a real of import cast inward Spring MVC framework, every bit it is used to charge your jump configuration files e.g. applicatoin-Context.xml together with others, defined inward the context-param chemical ingredient of web.xml of your Java jump spider web application, every bit shown below :
    <context-param>         <param-name>contextConfigLocation</param-name>         <param-value>classpath:application-Context.xml</param-value>     </context-param>      <listener>         <listener-class>             org.springframework.web.context.ContextLoaderListener         </listener-class>     </listener> 




Approach : Like whatever other ClassNotFoundException error, y'all root demand to honour out the JAR file on which this cast is bundled together with and thus add together that JAR into appropriate place, e.g. WEB-INF/lib folder of your spider web application. So that the spider web application cast loader e.g. org.apache.catalina.loader.WebappClassLoader tin run into this JAR file. You tin run into inward below stack delineate that it's the WebappClassLoader which failed to charge this cast :
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:1676)     at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521)     at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:415)     at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:397)     at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:118)     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:303)     at java.util.concurrent.FutureTask.run(FutureTask.java:138)     at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)     at java.lang.Thread.run(Thread.java:662)


Solution :  It appears that the jump context loader listener cast i.e. org.springframework.web.context.ContextLoaderListener  is moved to spring-web.jar since Spring 3.0. which agency y'all should create next to fix java.lang.ClassNotFoundException : org.Springframework.Web.Context.ContextLoaderListener fault :

1. If y'all are using Spring version 3.0 together with thus add together spring-web.jar into CLASSPATH i.e. precisely seat it within WEB-INF/lib folder.

2. If y'all are running inward Spring 2.0 or lower version together with thus precisely add together spring.jar into your application's CLASSPATH, same precisely seat it within WEB-INF/lib directory.

3. If spring.jar or spring-web.jar is already inward CLASSPATH together with thus your work is non due to JAR but due to wrongly configured classpath. See my post service how to bargain alongside ClassNotFoundException to troubleshoot  further.

4. If y'all are using Maven the add together next dependency inward your pom.xml file :
         <dependency>             <groupId>org.springframework</groupId>             <artifactId>spring-web</artifactId>             <version>3.2.6.RELEASE</version>         </dependency> 


5. If y'all are getting java.lang.ClassNotFoundException : org.Springframework.Web.Context.ContextLoaderListener error In Eclipse together with Tomcat, together with thus y'all tin likewise endeavour next steps to brand certain maven dependencies are inward CLASSPATH together with visible to Tomcat's spider web application cast loader. All y'all demand to create is add together maven dependencies into your eclipse project's spider web deployment assembly.
  • Select Project, Right click together with guide Properties.
  • Choose "Deployment Assembly".
  • Click the "Add..." push clit on the correct side.
  • Choose "Java Build Path Entries" from the bill of fare of directive type together with click "Next".
  • Select "Maven Dependencies" from the Java Build Path Entries bill of fare together with click "Finish".
You volition run into maven dependencies added to the spider web deployment assembly Definition past times now.

6. If  you are getting java.lang.ClassNotFoundException : org.Springframework.Web.Context.ContextLoaderListener error in previously working projection together with y'all are certain that y'all non done anything which causes this fault together with thus y'all tin try "Clean Tomcat Work Directory" or only "Clean..". This is supposed to discard all published acre together with republish from scratch.

This fault comes when y'all are using Spring MVC framework inward your Java Web application together with  java.lang.ClassNotFoundException: org.Springframework.Web.Context.ContextLoaderListener [Solution]


That's all virtually how to solve java.lang.ClassNotFoundException : org.Springframework.Web.Context.ContextLoaderListener error in Spring based Java spider web application. Mostly it's the illustration of missing the spring-web.jar file every bit hardly anyone is running alongside jump 2.0 now, but it's skillful to shout out upward that y'all demand to add together spring.jar into the cast path for older jump version together with spring-web.jar for newer jump version, starting from Spring 3.0.

Further Learning
Introduction to Spring MVC
Spring Master Class - Beginner to Expert
Spring together with Hibernate for Beginners
Spring MVC books together with resources
Spring Web Application Developer Certification

Thanks for reading this article thus far. If y'all similar this interview inquiry together with thus delight portion alongside your friends together with colleagues. If y'all accept whatever inquiry or proposition together with thus delight drib a comment together with I'll endeavour to honour an answer for you. 

Other mutual ClassNotFoundExceptions which comes inward Java programs :
  • General Guide to solve java.lang.ClassNotFoundException inward Java [guide]
  • How to solve java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver inward Java? [solution]
  • How to solve java.lang.ClassNotFoundException:org.Springframework.Web.Context.ContextLoaderListener [solution]
  • How to solve java.lang.ClassNotFoundException: com.mysql.jdbc.Driver inward 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 inward Java? [solution]
  • How to prepare java.lang.ClassNotFoundException: org.postgresql.Driver fault inward Java? [solution]

P.S. - If y'all desire to larn how to prepare RESTful Web Services using Spring Framework, banking firm fit out Eugen Paraschiv's REST alongside Spring course. He has lately launched the certification version of the course, which is sum of exercises together with examples to farther cement the existent earth concepts y'all volition larn from the course.

Subscribe to receive free email updates:

0 Response to "java.lang.ClassNotFoundException: org.Springframework.Web.Context.ContextLoaderListener [Solution]"

Posting Komentar