Tag Archives: java.lang.ClassNotFoundException: ContextLoaderListener

[Solved] Eclipse Error: java.lang.ClassNotFoundException: ContextLoaderListener

An error is reported after the Tomcat deployment project in eclipse is started:

Shell code

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:1678)

at   org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1523)

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)

problem background :

The project is a maven project, and the contextloaderlistener class is located in the spring-web-3.1.0.release.jar package. The pom.xml of Maven is checked and dependency introduction is normal. In the Maven dependencies view of the project, you can also see that the spring-web-3.1.0.release.jar package is introduced normally

 

error reason:

After entering the deployment path of Tomcat. Metadata \. Plugins \ org. Eclipse. WST. Server. Core \ tmp0 \ wtpwebapps \, it is found that the Lib directory is not generated in the WEB-INF folder after the project is deployed. Under normal circumstances, the Lib directory will be generated and all dependent jar packages of the project will be deployed to this directory

solution:

1. Right click the item – select properties

Select deployment assembly, click add on the right, and select Java build path entries in the pop-up window. As shown in the figure below:

2. Click Next and select Maven dependencies

3. Click finish, and you can see that Maven dependencies have been added to the web application structure

After the operation, redeploy the project and no more errors will be reported. Then we went to the. Metadata \. Plugins \ org. Eclipse. WST. Server. Core \ tmp0 \ wtpwebapps \ directory and found that the Lib directory was automatically generated under the WEB-INF directory of the project, and all dependent jar packages have been deployed. The problem is therefore solved