General solutions for java.lang.ClassNotFoundException under MAVEN projects

Source: Internet
Author: User

There are a lot of changes on the Web. Class. Project's trouble sometimes doesn't necessarily work. The following method is appropriate for a project with a jar already referenced. But the execution is classnotfound, please try for example:



Severity: Error Configuring 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 ( 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)

Issue Background :

Project is in the Spring-web-3.1.0.release.jar package for the Mavenproject,contextloaderlistener class. The pom.xml of Maven was checked, and the dependency was introduced properly.

In the Projectmaven dependencies view, it is also possible to see the Spring-web-3.1.0.release.jar package being introduced in the normal.


Cause of Error:

Enter the deployment path to Tomcat. Metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\ under the check, After you discover that project deployment has not generated a Lib folder under the Web-inf folder, it normally generates a Lib folder and deploys all of project's dependent jar packages to that folder.


How to resolve:

1. Right click on the project-select Properties

Select Deployment Assembly, click AddButton on the right, and select Java Build Path in the popup form Entries


2. Click Next. Choose Maven Dependencies


3. Click Finish to see that maven dependencies has been added to the Web application structure.


Once you're done, deploy project again. No more error. And then we go to the. metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\ folder, and found that the Projectweb-inf folder in the active generation of the Lib folder, And all of the dependent jar packages are already deployed. The problem is therefore resolved.

General solutions for java.lang.ClassNotFoundException under MAVEN projects

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.