File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Tomcat and the fly likes Tomcat Redeploy Breaks Struts App Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Tomcat Redeploy Breaks Struts App" Watch "Tomcat Redeploy Breaks Struts App" New topic
Author

Tomcat Redeploy Breaks Struts App

Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8997
    
    9

I have a problem with redeploying a WAR in Tomcat 5.5.20. Every time I drop a WAR into the $CATALINA_HOME/webapps directory the application becomes unusable, pages and servlets return 404's. So I tried the struts-blank-1.3.5.war that comes packaged with Struts and I get the same behavior:
-Drop the WAR into $CATALINA_HOME/webapps and it gets deployed:

-Point a browser at http://localhost:8080/struts-blank-1.3.5/ and I see some greeting text.
-Touch the WAR to force Tomcat to redeploy:

-Note that the redeploy is not as verbose as the deploy
-Navigate to http://localhost:8080/struts-blank-1.3.5/ and get a 404.

Stopping Tomcat and removing the exploded directories is really slowing down my development. Anyone else see the same thing?


[How To Ask Questions On JavaRanch]
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15300
    
    6

Usually that happens due to resource locking if developing on Winbloze. You should create a context for your webapp and apply a antiJARLocking="true" and antiResourceLocking="true" attributes for the context.

What's usually happening is during the undeploy process not everything is deleted so it can't redeploy the locked resources. I also create my context to point to my project folder where I maintain an "exploded" working copy of my webapp. So I have reloadable="true" for my context. Anytime I change a class file, tomcat reloads my webapps automatically. Also, because I work in a "hot" directory structure, I don't have to do a redeploy just to see changes I've made to JSP, CSS, etc.


GenRocket - Experts at Building Test Data
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8997
    
    9

I added those flags to my context file but when I do a redeploy it deletes the context file. But the application is usable after the redeploy.
I also tried using my build directory as the doc base as declared in the context below but it doesn't seem to catch on that web.xml has changed.

[ January 12, 2007: Message edited by: Joe Ess ]
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15300
    
    6

No, it won't catch config changes even though you would think it would with the watched resource param. I've never gotten that to work. Only classpath changes. You shouldn't really be messing with your web.xml file much after you get going anyway, so that won't be a big deal.

As far as the context file deletion, create a folder called META-INF in your project and put in there a context.xml file. In that file, specify your context config. Make sure you include that folder when you create the WAR file. When the war is deployed, the context.xml will be moved to

%TOMCAT_HOME/conf/Catalina/localhost/appname.xml

where appname is your context path as in

http://localhost:8080/appname

hth
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8997
    
    9

Originally posted by Gregg Bolinger:
No, it won't catch config changes even though you would think it would with the watched resource param.



I finally found the Context in the Tomcat documentation. Linked off the JNDI How-To. They sure don't make it easy.
Thanks for the help Gregg.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Tomcat Redeploy Breaks Struts App