Java – Using Cargo with Maven to remotely deploy WAR without HOT deployment

cargojavamaventomcat

We're using Cargo with Maven on a build server to remotely deploy a WAR file from our build server to an internal QA server for testing.

Our current POM for the project is seen below, and works properly for a hot deployment.

The problem is that instead of a hot deployment, we would like the Cargo plugin to stop the Tomcat instance, deploy the new WAR, and then start Tomcat. Is there a way to alter the POM to manage this scenario?

Our Maven build is defined as:

mvn clean deploy ... cargo:redeploy

And the cargo plugin settings in the POM:

                  <plugin>
                        <groupId>org.codehaus.cargo</groupId>
                        <artifactId>cargo-maven2-plugin</artifactId>
                        <configuration>
                            <container>
                                <containerId>tomcat7x</containerId>
                                <type>remote</type>
                                <systemProperties>
                                    <cargo.jvmargs>-XX:MaxPermSize=256M -Xmx1024m</cargo.jvmargs>
                                </systemProperties>
                            </container>
                            <configuration>
                                <type>runtime</type>
                                <properties>
                                    <cargo.hostname>qa-server</cargo.hostname>
                                    <cargo.servlet.port>8080</cargo.servlet.port>
                                    <cargo.tomcat.manager.url>http://qa-server:8080/manager</cargo.tomcat.manager.url>
                                    <cargo.remote.username>username</cargo.remote.username>
                                    <cargo.remote.password>pass</cargo.remote.password>
                                </properties>
                            </configuration>
                            <deployer>
                                <type>remote</type>
                                <deployables>
                                    <deployable>
                                        <groupId>com.ourcompany</groupId>
                                        <artifactId>myapp-artifactId</artifactId>
                                        <type>war</type>
                                        <properties>
                                            <context>latest</context>
                                        </properties>
                                    </deployable>
                                </deployables>
                            </deployer>
                        </configuration>
                    </plugin>

Best Answer

We had difficulties with Cargo. After a while, tomcat gets stuck and won't restart. Cargo does not permit to start/stop tomcat.

So what we eventually did was giving up cargo and using a script to restart tomcat at a distance from our jenkins machine. Also we share a folder on the integration machine used to deploy our wars. We also use the maven assembly plugin for our conf files and folders.

Related Topic