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 deploying to tomcat from ant Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "deploying to tomcat from ant" Watch "deploying to tomcat from ant" New topic
Author

deploying to tomcat from ant

paul wheaton
Trailboss

Joined: Dec 14, 1998
Posts: 20526
    ∞

It's been years since I've worked with tomcat, so please forgive me my newbie questions ....

I wish to make sure that each time I call "ant deploy", that I get a really clean, fresh, installation into tomcat. My guess is that tomcat supports autoloading of new war file but that it might be a bit shaky. So I'm guessing that my deploy should ask tomcat to shut down, then I would need to remove all of the old files where tomcat unpacked my old war file, then copy over the new war file and then start tomcat back up again.

Does this sound right?

Does anybody have any ant snippets of doing something like this?


permaculture Wood Burning Stoves 2.0 - 4-DVD set
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

There is one in Tomcat's "First App Tutorial" written by Craig R. McClanahan on this page:
http://tomcat.apache.org/tomcat-5.5-doc/appdev/source.html

That tutorial makes for a nice refresher course if you've been away from Servlet apps for a while.
[ January 13, 2006: Message edited by: Ben Souther ]

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

I haven't come across any issue of just copying the file and allowing it to be redeployed. For instance, using JBoss, the only time I have had to reboot the server is when I have a dependency on a .jar file that is in the lib directory of the server, and not in the "app". But within an ear or a war they work fine.

That situation of rebooting had to do with which class loader actually loaded the classes from the jar file. And since the jar in the server's lib directory is loaded by a different classloader than the app's .ear or war file class loader, it causes a problem.

But, in the end redeploying just a .war or .ear file should work fine without having to reboot the server.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

I've used Tomcat's Ant Tasks for this type of thing in the past. Prior to Tomcat 5.5 everything seemed to work great. However, since 5.5 they don't have the same behavior. I start up tomcat like normal. I can run the deploy task and it basically copies my WAR file to the webapps folder. This works fine. But after that point, things don't work.

If I run the stop task, which just stops the webapp, not tomcat, and then execute the start task, it doesn't start back up and I get SEVERE errors. If I try and undeploy, it removes everything except what Tomcat has a hold of such as JAR files and the context.xml file. Then trying to deploy after that I get more errors and exceptions.

So I am at a loss as to what to do. Mark's suggestion isn't working either. Simply copying the WAR file into the webapps folder again throws more errors and exceptions at time. I honestly think this aspect of Tomcat is rather buggy.


GenRocket - Experts at Building Test Data
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

On an added note, using the Manager interface through the browser has the same results as the Ant Tasks.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by Gregg Bolinger:
On an added note, using the Manager interface through the browser has the same results as the Ant Tasks.


The Ant tasks merely call the manager's commands.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: deploying to tomcat from ant