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

Deployment to tomcat 6 programmatically

John Farrel
Ranch Hand

Joined: May 24, 2010
Posts: 83
Hi,

I am writing a Java system to deploy builds across many tomcat installations, and I'm looking for the cleanest way to do it.
Is there an API for talking to the various tomcat managers where I could undeploy an app and deploy a new version?

John
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16020
    
  20

Yup. I even did a little contributing to it in a way.

There was a JSR for a webapp deployment and control interface: JSR-88, which I think has since been upgraded to a newer JSR. It was based on the idea that every webapp deployment consisted of a deployable unit with container-independent deployment descriptor (WEB-INF/web.xml) and a separate container-dependent deployment descriptor (which for Tomcat is the Context).

So if it amused you, you could write your own deployment program.

But wait - there's more! Ant has a deployment task. Maven has a deployment goal. Tomcat has the ability to invoke the manager as a web service (IIRC). Possibly also via JMX.

In other words, there are more ways to automate than I can easily recall, and those are just the J2EE-approved ways. My own deployments are via OS-native packages (since things like database schema tweaks and construction of external support directories are a bit awkward using only a WAR). I put them on a provisioning server and add them to the server's software inventory profiles.


Customer surveys are for companies who didn't pay proper attention to begin with.
Aniruddh Joshi
Ranch Hand

Joined: Jul 29, 2008
Posts: 275

A colleague told me weblogic deployment scripts are developed using Python.
Also you can look at how eclipse WTP does deployments.


Anrd
"One of the best things you could do is to simplify a larger application into a smaller one by reducing its process and complexity - Fowler"
John Farrel
Ranch Hand

Joined: May 24, 2010
Posts: 83
Tim Holloway wrote:Yup. I even did a little contributing to it in a way.

There was a JSR for a webapp deployment and control interface: JSR-88, which I think has since been upgraded to a newer JSR. It was based on the idea that every webapp deployment consisted of a deployable unit with container-independent deployment descriptor (WEB-INF/web.xml) and a separate container-dependent deployment descriptor (which for Tomcat is the Context).

So if it amused you, you could write your own deployment program.

But wait - there's more! Ant has a deployment task. Maven has a deployment goal. Tomcat has the ability to invoke the manager as a web service (IIRC). Possibly also via JMX.

In other words, there are more ways to automate than I can easily recall, and those are just the J2EE-approved ways. My own deployments are via OS-native packages (since things like database schema tweaks and construction of external support directories are a bit awkward using only a WAR). I put them on a provisioning server and add them to the server's software inventory profiles.


Excellent. I had known about ant and maven and my backup was to run these as external processes.
Could you point me to any resource that describes how I can do this in java? What libraries do I need?

thanks,

John

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16020
    
  20

I worked with a specific JSR-88 implementation called "Ishmael" for the JOnAS J2EE server. I think that now the client SPI is part of the stock J2EE jar that Sun/Oracle distributes as part of their reference implementation.

Your best bet if you want to roll your own Java client is to get hold of the J2EE SDK and download the JSR-88 specification docs. You might want to pick up the JSR-77 docs as well. JSR-77 is more about control than deployment, but there's some overlap.

Also check out code.google.com and this page: http://tomcat.apache.org/tomcat-5.5-doc/catalina/funcspecs/mbean-names.html

And the master JavaDoc: http://docs.oracle.com/javaee/6/api/javax/enterprise/deploy/model/package-summary.html#package_description

Finally, there's this: http://cargo.codehaus.org/Home

Alternatively, look at the Tomcat Client Deployer, described here: http://tomcat.apache.org/tomcat-5.5-doc/deployer-howto.html . The Tomcat Client Deployer acts as a client to the Tomcat Manager webapp. Unless I'm mistaken, this is not a JSR-88 deployer, but it probably qualifies as a Web Service-based deployer.

John Farrel
Ranch Hand

Joined: May 24, 2010
Posts: 83

Thanks for all that.

It looks like the fastest way to get this running will be to use codehaus.
Shame that tomcat manager doesn't have a SOAP web service available, because I could get that running very quickly.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16020
    
  20

John Farrel wrote:
Thanks for all that.

It looks like the fastest way to get this running will be to use codehaus.
Shame that tomcat manager doesn't have a SOAP web service available, because I could get that running very quickly.


Well, i think that Tomcat Manager uses REST, actually.
John Farrel
Ranch Hand

Joined: May 24, 2010
Posts: 83

I'm looking at my Tomcat installation and can find neither wsdl or wadl for the manager.
Any ideas?

John.
John Farrel
Ranch Hand

Joined: May 24, 2010
Posts: 83
Ahh... I'm too used to SOAP. REST doesn't really work the same way.

 
jQuery in Action, 2nd edition
 
subject: Deployment to tomcat 6 programmatically