Search code examples
eclipsetomcatdeploymenttomcat6eclipse-kepler

Eclipse with Tomcat does not automatically republish my WAR file


I've got Windows 8.1 with a 1.6 JDK manually installed.

I'm using Eclipse (Kepler, Java EE IDE for Web Developers). I imported a project that builds a WAR file using an Ant build script; that shows up as a Project. I created a Tomcat6 Server (downloading the available Eclipse package); that shows up as a second Project.

On the Modules tab for the Server, I clicked "Add External Web Module...", browsed to the folder holding my WAR file and clicked OK. I then added the name of my WAR file (directory name "...\SpiffyApp" to file name "...\SpiffyApp\spiffyapp.war"). I confirmed that the name of the path is "/"; I clicked to have "Auto reloading enabled" checked, and clicked OK.

I admit - I peeked inside the Server configuration. I clicked on "Open launch configuration"; in dialog "Edit launch configuration properties", on the Arguments tab, I discovered the following property setting:

-Dcatalina.base= "....metadata.plugins\org.eclipse.wst.server.core\tmp0"

Then in my mischief I observed that the "tmp0" directory had a "webapps" subdirectory. Aha!

I notice that, under some circumstances, the "SpiffyApp" is republished under "webapps" - problem is, I can't figure out when!

Specifically, I'm disappointed that Eclipse doesn't republish my app to "webapps" when I tell the server to "Clean"/"Publish". What I'd really like is for it to republish automatically when I rebuild the WAR.

I can get the WAR redeployed when I do all of this:

  1. stopped my Tomcat Server
  2. delete all folders under "tmp0/webapps"
  3. delete all folders under "tmp0/work" (tip I got from Chris Lercher, here)
  4. rebuilt my WAR file
  5. Started my Server

Surely I'm doing something wrong.

What are the rules here? Am I really left to remove the Web Module, delete the folder in "tmp0" and re-add the Web Module?


Solution

  • What you're doing wrong is expecting it to watch for changes on an archive file, which generally isn't expected to change. Import the WAR as a project and then Eclipse can deploy it properly when something actually changes within the app.

    Otherwise you might try forcibly Cleaning the server area from the context menu of the Tomcat server instance in the Servers View.