Error configuring application listener of class ContextLoaderListener Solution



The ContextLoaderListener class is used to integrate Spring framework with other web application

<!-- it is web.xml file --> <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/Spring-Config/applicationContext.xml</param-value> </context-param> <listener> <listener-class> org.springframework.web.content.ContextLoaderListener </listener-class> </listener>

Exception Stack Trace:

SEVERE: Error configuring application listener of class org.springframework.web.context.ContextLoaderListener java.lang.ClassNotFoundException: Caused by: org.springframework.web.context.ContextLoaderListener at org.apache.catalina.loader.WebappClassLoader.loadClass( at org.apache.catalina.loader.WebappClassLoader.loadClass( at org.apache.catalina.core.StandardContext.listenerStart( at org.apache.catalina.core.StandardContext.start( at org.apache.catalina.core.ContainerBase.start( at org.apache.catalina.core.StandardHost.start( at org.apache.catalina.core.ContainerBase.start( at org.apache.catalina.core.StandardEngine.start( at org.apache.catalina.core.StandardService.start( at org.apache.catalina.core.StandardServer.start( at org.apache.catalina.startup.Catalina.start( 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( at org.apache.catalina.startup.Bootstrap.main(


This happens both in debugging and deployment environment.

1.Deployment environment

In deployment environment, you to make sure that your server classpath has the Spring jar library (e.g spring 3.0 jar).

For Spring 5, ContextLoaderListener is moved to spring-web.jar, you can get the library from Maven central repository.

add maven dependency for spring-web.jar

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

2.Debugging environment

In debugging environment, the steps may differ from one IDE to another IDE, but the solution is same. In Eclipse, developers usually use a tomcat or jboss server for debugging, just cross chack that correct Spring jars are included.

1. Double click on your server

2. Open launch configuration to access the server environment

Image of web.xml

3. Click on the classpath tab

4. Include the Spring jar file here, sometimes common log jar is also required due to Spring dependency.

Image of web.xml

5. Done, run your application again. You will not get that exception again.

Solution Worked 0 UpvotesUpvote


Solution Didn't Worked 0 DownvotesDownvote


Get Programming Help

Play 2048 Game Online

Search Tags