Java Web Project not building correctly

Dennis Röttger picture Dennis Röttger · Jul 11, 2012 · Viewed 24.9k times · Source

I've got a Java Web Project which I'm deploying to a Tomcat embedded in Eclipse's Servers Plugin, alas, when I navigate to the location of that webapp after publishing/starting the server, the .class files are all missing. I can navigate as far as ProjectName\WEB-INF\classes\path\to\packages\ -> All packages are empty.

Any Idea how to solve this problem?

Edit

Build Automatically is checked and it compiles just fine for another web project I've just included, just not for the one specified

Edit 2

Reinstalled Eclipse (because why not) - nothing's changed, works for Project #2, doesn't work for Project #1. Not even the path to the packages is existant now. The content of the src folder (that's supposed to be moved to WEB-INF/classes) isn't there at all - but the resources (I've got a resources folder with the same deployment assembly command) are.

Answer

Konstantin Komissarchik picture Konstantin Komissarchik · Jul 11, 2012

A few steps to perform to restore sanity...

  1. Refresh your project. It is possible that something was modified on the file system external to Eclipse.

  2. Kick of Project -> Clean.

  3. Now look at your project (not the deployed location) on the file system. Do you see the expected files in the /bin directory (or whatever you may have changed class output directory to)?

  4. Let's now try exporting a war using the wizard. File -> Export -> Web -> WAR or something like that. Check the WAR contents. Are you .class files there?

  5. If everything is good so far, there is nothing wrong with your project. The Tomcat server adapter just got confused.

  6. In the Servers view... Make sure Tomcat is running. Next right click on Tomcat and select add/remove projects. Remove your project. Confirm that your web app is no longer accessible.

  7. Now re-add your project via add/remove projects or invoke one of the run as actions.

The above should reset Tomcat server adapter and hopefully things should work as expected.