Meaningless Drivel is fun!*
The moose likes Tomcat and the fly likes How to redeploy a webapp that already exists Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "How to redeploy a webapp that already exists" Watch "How to redeploy a webapp that already exists" New topic
Author

How to redeploy a webapp that already exists

Steve Dambrosio
Greenhorn

Joined: Apr 02, 2009
Posts: 28
Greetings! I'm running Tomcat 6.0 as a Windows XP Service. I'm trying to redeploy a webapp by stopping tomcat, dropping a war file into the webapps folder that is newer than the exploded webapp, and then restarting tomcat. This doesn't work - tomcat does not remove the exploded webapp and seems to ignore the new war file. The following excerpt from tomcat docs implies that it will *not* work because my webapp *is* referenced by a Context Descriptor (and it needs to be because I have a Resource defined) - but I figure I don't understand thing correctly yet and that maybe it can work.

The following deployment sequence will occur on Tomcat startup in that case:

Any Context Descriptors will be deployed first.
Exploded web applications not referenced by any Context Descriptor will then be deployed. If they have an associated .WAR file in the appBase and it is newer than the exploded web application, the exploded directory will be removed and the webapp will be redeployed from the .WAR
.WAR files will be deployed


The only way to get it to work is to remove the exploded webapp (I also remove the one in tomcat's work folder but don't know if I need to). My host has autoDeploy="false" and deployOnStartup="true" (although I've tried other combinations). Is there any way to get tomcat to remove the old expoded webapp? Or, is there a best practice that I need to be educated on! Thanks! BTW, here's my context:




Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15950
    
  19

Unfortunately, Tomcat sees the exploded and unexploded versions of the WAR as 2 separate webapps, and since that's a conflict, it always resolves by using the exploded version, even when it's older.

No, Tomcat will not delete the obsolete version. I use a shell script to do that as well as removing old log and work files.

You can eliminate the problem by configuring Tomcat to not explode the WAR, but that's about the best you can do.


Customer surveys are for companies who didn't pay proper attention to begin with.
Steve Dambrosio
Greenhorn

Joined: Apr 02, 2009
Posts: 28
Thanks very much for the info. What's your opinion on deleting the work folder? (in my case C:\Program Files\Apache Software Foundation\Tomcat 6.0\work\Catalina\localhost\<webapp>). It seems to work fine if I don't delete it but I see that tomcat leaves old files in there (compiled jsp's for example).

P.S. Hot deployment seems to work great (autoDeploy="true"). I can drop in a new war file and the app gets re-exploded before my very eyes, or I can delete the exploded folder and it gets recreated from the existing war.
Steve Dambrosio
Greenhorn

Joined: Apr 02, 2009
Posts: 28
When you say
No, Tomcat will not delete the obsolete version. I use a shell script to do that as well as removing old log and work files.
, are the work files you're talking about the ones in work/Catalina/localhost? I.e. when redeploying an existing application should I delete the application folder in work/Catalina/localhost?
Steve Dambrosio
Greenhorn

Joined: Apr 02, 2009
Posts: 28
When you say
No, Tomcat will not delete the obsolete version. I use a shell script to do that as well as removing old log and work files.
, are the work files you're talking about the ones in work/Catalina/localhost? I.e. when redeploying an existing application should I delete the application folder in work/Catalina/localhost?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60741
    
  65

No.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Steve Dambrosio
Greenhorn

Joined: Apr 02, 2009
Posts: 28
Thanks for the reply Bear. Can I assume from your reply that I don't have to worry about what's in work/Catalina/localhost regardless of how I deploy? For example, I may deploy by deleting the old application folder in webapps and exploding the .war war file manually (using jar).
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60741
    
  65

Oops. I thought you were asking about the files in conf/Catalina, rather than work/Catalina. My bad.

Yes, if you want to make sure that you are starting off with a clean slate, remove the files in work/Catalina for the web app. (e.g. work/Catalina/localhost/whatever)

Unless you want to change settings, you don't need to worry about the files in conf/Catalina.
 
Don't get me started about those stupid light bulbs.
 
subject: How to redeploy a webapp that already exists
 
Similar Threads
Can't write Context element properly
Tomcat Redeploy Breaks Struts App
tomcat 6 WAR deployment
A Realm for more than one Webapp
files in WEB-INF/classes not found?