• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Ant ServerDeploy Option for Tomcat

 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

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. http://ant.apache.org/manual/OptionalTasks/serverdeploy.html#serverdeploy_element

But how can I use this task for Tomcat?


Thanks for your help in advance
Srinivas Ivaturi
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
reply
    Bookmark Topic Watch Topic
  • New Topic