Solutions for Java.lang.ClassNotFoundException

Source: Internet
Author: User

There may be many reasons for this problem, but the final cause is that there is no such package in the deployed project file.

So where's the wrong point? Exclude each!

1. The appropriate jar package is not added to the project file first, and can be seen in the Maven Dependencis folder. If not, add a dependency configuration in the Pom file, or if so, the problem goes to the second step

2. Find the corresponding jar package file in Maven's local repository, double-click try to open it, if there is an error saying that the file is damaged or incomplete (I guess it may be that the previous Maven download was interrupted because of the network, no download completed,

The next time the Pom in the Maven warehouse to introduce the local jar package will not be downloaded from the official website, directly take the last torn file, so it will be wrong, the solution is to remove the jar package file, re-update the pom file, let maven re-download the jar to the local repository.

If you find that the jar package for the local repository does not get an error, then go to the third step.

3. The final reason is that the MAVEN project's jar package is not published to the deployed project file. Enter the deployment path to Tomcat. Metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\ under the check, hair

Now that the project is deployed, the Lib directory is not generated under the Web-inf folder, and under normal circumstances, the Lib directory is generated and all dependent jar packages for the project are deployed to that directory.


1). Right click on Project-Select Properties

Select Deployment Assembly, click the Add button on the right, and select Java Build Path Entries in the popup window. As shown in the following:

2). Click Next to select Maven Dependencies

3) Click Finish, and you can see that maven dependencies has been added to the Web application structure.

After the operation, redeploy the project, no longer error. Then we go to the. Metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\ directory, found in the project Web-inf directory automatically generated Lib directory, And all the dependent jar packages have been deployed. The problem is therefore resolved.

Solutions for Java.lang.ClassNotFoundException

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: 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.