[Solved] java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener

If you are working on a web application based on spring which requires use of org.springframework.web.context.ContextLoaderListener in web.xml file and you are getting this exception when you start the server. This exception is more likely when you are working on eclipse or possibly on other such IDE.

Exception log trace will look like this:

May 15, 2014 12:16:20 AM 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.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)

May 15, 2014 12:16:20 AM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Skipped installing application listeners due to previous error(s)
May 15, 2014 12:16:20 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error listenerStart
May 15, 2014 12:16:20 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/Spring4Struts2HibernateIntegration] startup failed due to previous errors
May 15, 2014 12:16:20 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
May 15, 2014 12:16:20 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
May 15, 2014 12:16:20 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 365 ms

exceptions-notes

Solution

Reason 1)

Possibly you have not added the spring web dependencies in your project. Just add them if you have not.

Reason 2)

If you are still getting this exception then you must add these dependencies to project deployment assembly as well.

To add dependencies in deployment assembly follow below instructions.

1) Open project properties and select Choose Deployment Assembly. Then select option “Java Build Path Entries”.

Deployment assembly option

2) Click Next and select all jar files. Click Finish.

Select all jars

3) Deployment assembly will look like this. Click Apply.

Apply deployment assembly

Above fixes will solve the issue.

Happy Learning !!

23 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments

Comments are closed for this article!

About Us

HowToDoInJava provides tutorials and how-to guides on Java and related technologies.

It also shares the best practices, algorithms & solutions and frequently asked interview questions.