General Solutions for java. lang. ClassNotFoundException in Maven

Source: Internet
Author: User

It is difficult to modify. class. project on the Internet, and sometimes it may not work. The following method is suitable for projects that have referenced jar, but ClassNotFound is used at runtime. Try the following method:



Severe: Error Processing ing application listener of class org. springframework. web. context. contextLoaderListenerjava. lang. classNotFoundException: org. springframework. web. context. contextLoaderListenerat 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 (defainstinstancemanager. 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. Check the maven pom. xml, and the 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 cause:

Enter the tomcat deployment path. metadata \. plugins \ org. eclipse. wst. server. core \ tmp0 \ wtpwebapps \ check, found that after the project is deployed in the WEB-INF folder did not generate the lib directory, under normal circumstances, the lib directory is generated and all the dependent jar packages of the project are deployed under this directory.


Solution:

1. Right-click the project and choose Properties.

Select Deployment Assembly, click Add on the right, and select Java Build Path Entries in the pop-up window.


2. Click Next and select Maven Dependencies.


3. Click Finish and you will see that Maven Dependencies has been added to the Web application structure.


After the operation, redeploy the project and no error is reported. Then we will go. metadata \. plugins \ org. eclipse. wst. server. core \ tmp0 \ wtpwebapps \ directory, found that the lib directory is automatically generated under the project WEB-INF directory, and all the dependent jar packages have been deployed. Solve the problem.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.