File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Ant, Maven and Other Build Tools and the fly likes Ant ServerDeploy Option for Tomcat Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Ant ServerDeploy Option for Tomcat" Watch "Ant ServerDeploy Option for Tomcat" New topic

Ant ServerDeploy Option for Tomcat

Srinivas Ivaturi
Ranch Hand

Joined: Jan 28, 2003
Posts: 50

I want to deploy the .WAR file via ant build.xml into Tomcat web application folder. I found ServerDeploy is the task which can be used for this.

But how can I use this task for Tomcat?

Thanks for your help in advance
Srinivas Ivaturi
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17410

This task is for appservers that appservers that support the JSR-188 mechanism for deployment, configuration (in conjunction with JSR-77) and control (start/stop) of webapps (meaning WARs, EARs, JARs and CARs).

Neither Tomcat nor, for that matter IBM's WebSphere (as of WebSphere 6) serve up JSR-188, so the answer is no.

I do have several tricks of my own for deployment, however. For testing, I have a build directory and in it, I build the exploded WAR which will be used as input to the WAR task. Since Tomcat can work with exploded WARs, I place an XML config file in the Tomcat webapps directory that resolves the app's context to the absolute pathname of the exploded WAR directory.

For production, I run the WAR step. Mostly, I deploy in Solaris packages, since I often have non-J2EE tasks to perform as part of the install process as well, so I use the "exec" task to run the Solaris package tools.

Deploying into Tomcat generally consists of simply copying the WAR to the appropriate directory (Tomcat 4: TOMCAT_HOME/webapps, Tomcat 5: TOMCAT_HOME/conf/Catalina/localhost...) Alternatively, you can copy the webapp to an external directory and do like I do on test systems, using a webapp config xml (Context) file to locate the WAR (I place mine in /opt/webapps).

In tomcat 4, you can't place BOTH the webapp config file and the WAR in the TOMCAT_HOME/webapps directory, because the WAR will hide the xml file, and in my case, the XML file holds the security realm definitions (I prefer discrete Context files over dumping them all into TOMCAT_HOME/conf/server.xml - it's easier to (de)install/update them that way.

In Tomcat 5, the webapps directory holds shared deployments and the server-specific config info goes into TOMCAT_HOME/Catalina/xxxx...etc. So it's not an issue.

Since these are all just files and directories, the Ant copy task is all you need to deploy on a local machine.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: Ant ServerDeploy Option for Tomcat
It's not a secret anymore!