简体   繁体   中英

Java ClassNotFoundException under Tomcat in Eclipse

I have been all over existing posts that deal with the ClassNotFoundException running a Java web app under Tomcat in Eclipse.

I am unable to provide source code and configuration artifacts because I am working on a proprietary code base. However, through trial and error I have boiled the problem down to its basic elements.

I have project packaged by Maven as a WAR. There are a number of other projects in the workspace on which the primary package depends. This arrangement has been working fine: I can deploy the WAR and the JARs it depends on under a Tomcat instance in Eclipse and the application runs and I can debug it.

Now I have created a new project that for the moment contains a single public class with a public constructor. The maven build works fine and the Eclipse compile workspace works fine. However, when I deploy to Tomcat and exercise an execution path that instantiates the class in the new project, I get a ClassNotFoundException.

I have checked the following items:

  • The Web Deployment Assembly for the primary package's project specifies WEB-INF/lib/ as the Deploy Path for the new project;
  • The JAR for the new project does in fact end up in the WEB-INF/lib/ folder under the actual deployment folder;
  • When I do a clean and publish on the server, the contents of the actual deployment folder do in fact get nuked and get repopulated with all the right JARs;
  • The new project's JAR as I find it the WEB-INF/lib in the deployment folder does in fact contain the class I am trying to instantiate;
  • The Tomcat log (which includes the startup cycle) contains no errors other than than the ClassNotFoundException;
  • I have re-done the Maven build and applied Maven build to the Eclipse projects numerous times;
  • I have cleaned and rebuilt in Eclipse numerous times;
  • I have cleaned and republished to the web server in Eclipse countless times;
  • I have created several new server instances.

Based on existing discussions of the ClassNotFoundException-in-Tomcat problem, these are the only things I have found to check. What else should I be looking into?

Thanks for your help.

Even for me the same problem has occurred .... I have clean the Tomcat and the Tomcat work directory and run the project again it worked fine...

This may happen because of the cache, sometimes which is not cleaned properly while building the application.

sometimes deleting the project from the eclise and importing it again doing it from scratch will also clear the problem

I'm not sure what exactly was wrong. However, I ended up resolving this issue by removing the project from the workspace, re-creating it from scratch, and importing my class into the re-created project.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM