3

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.

6
  • 1
    so what class is missing? Quite possibly a versioning problem Commented Apr 16, 2015 at 1:02
  • @ScaryWombat: Do you mean that the JAR doesn't contain the current version of the class? Or that the primary project is looking for a different version of the new JAR? Commented Apr 16, 2015 at 1:10
  • If you had jar1 that depends on jar2 that has method doMe in it, but you included jar2.2, and jar2.2. does not have the method doMe in it, then you will have trouble. Often happens with logging jars. Commented Apr 16, 2015 at 1:13
  • you can use something like findjar.com to find the jar file the class that is missing would be in - in case its not one of your own project. Commented Apr 16, 2015 at 2:59
  • @ScaryWombat: dude, you're onto something. If I do jar tf to list the contents of the jar, the class is there. But if I use javap to inspect the class I get "class not found." But I don't think this is as simple as a versioning issue. Commented Apr 16, 2015 at 13:24

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.