It's not a secret anymore!*
The moose likes Tomcat and the fly likes Hot deployment problems Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Hot deployment problems" Watch "Hot deployment problems" New topic
Author

Hot deployment problems

Janko Mlakar
Greenhorn

Joined: Mar 20, 2010
Posts: 7
I have to deploy a war file named abc.war to tomcat 6.0.18 on RHEL 4.6 with no restarting (if possible) of tomcat service (due other applications running on same machine).

I copied abc.war file to webapps directory using shell script. Tomcat auto deploy abc.war and make abc folder so i can access application via http://_Server_ip_/abc

If I need to update application abc with new abc.war I'm stuck in a lot of cases as hot auto deploy don't work and i need to restart tomcat to make it work.
I upgraded script with option to delete old abc.war file from webapps and wait 30 seconds (should i wait more?) for tomcat to remove abc folder before copying new abc.war file. If there is no removal of abc folder (by tomcat) i delete it before copying new war file. After copy of new abc.war file I wait for auto deploy.
In most cases i need to restart tomcat for deploying (making abc folder).
Sometimes deploy works, but i got 404 while accessing the application and i need to restart tomcat anyway.

I noticed there is a $CATALINA_HOME/work/localhost/abc folder and in $CATALINA_HOME/conf/localost/abc.xml (I'm writing names and location from my head so there might be a slightly different folder names). I wonder should i delete them too before copying new war file? Should i add some sleep timer before copying new war file?

Maybe I'm doing something wrong?

Please advice me, how to proceed to make upgrades more robust without so many restarts.
Rajkamal Pillai
Ranch Hand

Joined: Mar 02, 2005
Posts: 443
    
    1

Hi,

I have worked with differnet IDE including Eclipse, Netbeans, RAD etc. I also employ hot deployment. I understand that I do not need to restart my server on modification of JSP files. If I am changing my Java classes, XML configuration files, properties files etc I invariable have to go for a server restart.

Cheers,
Raj.
Janko Mlakar
Greenhorn

Joined: Mar 20, 2010
Posts: 7
That makes sense... is there any workaround?
If i removed abc.war file would it be consider as un-deploy? If I copy new war afterward should it be deployed and running without needed of restart?

Whats the meaning of $CATALINA_HOME/work/localhost/abc? As far i remembered sometimes it stays there even i removed abc.war file.
shivendra tripathi
Ranch Hand

Joined: Aug 26, 2008
Posts: 263
Java classes can be hot deployed (if changes are minor like putting sysout, modifying some logic inside method)you need restart only in case of configuration files.


SCJP 1.5(97%) My Blog
Rajkamal Pillai
Ranch Hand

Joined: Mar 02, 2005
Posts: 443
    
    1

Hi,


Java classes can be hot deployed (if changes are minor like putting sysout, modifying some logic inside method)you need restart only in case of configuration files.


The code changes are not always reflected on a hot deployment.


Cheers,
Raj.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16142
    
  21

Hot deploy is an option. It requires that Tomcat periodically rescan the application to detect changes, Since this is overhead, production servers sometimes disable that option.

My experience is that changes to config files and to the init() methods of servlets isn't handled very well (if at all) by hot updating. Changes to other classes and files do better.

The update process does tend to take a few seconds, though, as the old copy of the app will be unloaded and the new copy gets loaded. During part of that time, page requests will return 404, so you may just need more patience.

I don't recommend deleting the conf file. Deleting the workfiles is more or less "safe", although I don't know what pathological cases might exists. Updating the conf file will itself cause an app to restart so it can pick up any new config options coming from the context.

For totally safe operation, use the Tomcat console to stop the app before redeploying.

And, in tomcat 6, don't be surprised if memory issues force you to restart the whole server occasionally. It's bad about that.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hot deployment problems