Class Not Found Exception org.springframework.web.context.ContextLoaderListener
Sometimes, when we build a project using maven, we find the error " Class Not Found Exception org.springframework.web.context.ContextLoaderListener " even after the necessary dependencies to Spring libraries have been added (spring-web.jar file in the lib directory of the final artifact). It works fine if the application is deployed from outside the eclipse.
On deploying it within IDE , it shows the following error:
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:506)
at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:488)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:115)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4932)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5528)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)
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)
To avoid this, we need to add maven dependencies in the project's web deployment assembly.
1) Goto Project properties.
2) Select "Deployment Assembly".
3) Click the "Add..." button .
4) Select "Java Build Path Entries" and click next.
5) Then select "Maven Dependencies" from the Java Build Path Entries menu and click "Finish".
This will publish the Maven dependency JAR files to the lib folder.
0 Comment(s)