Maven Tomcat Deployment using Cargo
Last Updated on Wednesday, 13 March 2013 20:42
There is a nice plugin for Maven called Cargo which simplifies deployment on different servlet container massively. With Cargo Maven Plugin you can manage different containers which are installed, start, stop fully automatic.
Cargo also performs the deployment of the webproject to the specific container(s). Thus we can really kickstart web development with a properly configured project. If this is not the case step into the tutorial configuring a webproject to simplify team development and testing first.
The project is configured properly for Cargo if the pom-file contains a plugin configuration for the cargo-maven2-plugin artifact which itself contains some container configuration as shown below:
Include the following snippet in the <build><plugins> section of your project's pom.xml-file:
Include the following snippet in the <profiles> section of your project's settings.xml-file:
This will activate based on OS settings. The Maven profile Unix with be activated because OSX is part of the family unix. catalina.home will be then available as a property.
To try the Cargo deployment simply use:
To try the Cargo undeploy simply use:
The context root of a web application determines which URLs Tomcat will delegate to your web application. If your application's context root is webapp then any request for /webapp or /webapp/* will be handled by your application unless a more specific context root exists. If a second web application were assigned the context root myapp/help, a request for /webapp/help/help.jsp would be handled by the second web application, not the first.
Include or update the following snippet in the <deployer> section of your maven cargo plugin definition:
In this definition we are using the artifactId of the project to define the web context
If you have any remark or questions feel free to put a comment.If you enjoyed this tutorial and want to promote it don't hesitate to click on