Java – Tomcat cannot start components using cargo maven

Tomcat cannot start components using cargo maven… here is a solution to the problem.

Tomcat cannot start components using cargo maven

I’m trying to deploy a war file to Tomcat, using the cargo maven plugin on port 8080 (I checked, it’s free) and I get catalina. LifeCycleException: Failed to start component [Connector[AJP/1.3-auto-1]]

Error Stack

It also says that the port number entered is invalid, but the port is specified in the server.xml file: <Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />

Am I missing some other configuration?

cargo configuration:

<plugin>
            <groupId>org.codehaus.cargo</groupId>
            <artifactId>cargo-maven2-plugin</artifactId>
            <version>1.4.14</version>
            <configuration>
                <container>
                    <containerId>tomcat8x</containerId>
                    <type>installed</type>
                    <zipUrlInstaller>
                        <url>http://repo.release.cerner.corp/external/repo/org/apache/tomcat/apache-tomcat/${apache.tomcat.version}/apache-tomcat-${apache.tomcat.version}.tar.gz</ url>
                    </zipUrlInstaller>
                    <dependencies>
                        <dependency>
                            <groupId>com.oracle</groupId>
                            <artifactId>ojdbc6</artifactId>
                        </dependency>
                    </dependencies>
                    <timeout>300000</timeout>
                </container>
                <configuration>
                    <configfiles>
                        <configfile>
                            <file>${project.basedir}/src/test/resources/context/context.xml</file>
                            <todir>conf</todir>
                        </configfile>
                    </configfiles>
                    <properties>
                        <cargo.servlet.port>${apache.tomcat.servletPort}</cargo.servlet.port>
                        <cargo.rmi.port>${apache.tomcat.rmiPort}</cargo.rmi.port>
                        <cargo.tomcat.ajp.port>${apache.tomcat.ajpPort}</cargo.tomcat.ajp.port>
                        <cargo.logging>low</cargo.logging>
                        <!--uncomment to enable debugging on the server-->
                        <!--<cargo.jvmargs> "-Xdebug" "-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=7998"-->
                        <!--</cargo.jvmargs>-->
                    </properties>
                </configuration>
                <deployables>
                    <deployable>
                        <groupId>${project.groupId}</groupId>
                        <artifactId>sample-war</artifactId>
                        <type>war</type>
                        <properties>
                            <context>sample-war</context>
                        </properties>
                    </deployable>
                </deployables>
            </configuration>
            <executions>
                <execution>
                    <id>start-container</id>
                    <goals>
                        <goal>start</goal>
                    </goals>
                    <phase>pre-integration-test</phase>
                </execution>
                <execution>
                    <id>stop-container</id>
                    <goals>
                        <goal>stop</goal>
                    </goals>
                    <phase>post-integration-test</phase>
                </execution>
            </executions>
        </plugin>
    </plugins>

Solution

Change the port number in cargo configuration

<configuration>
      <properties>
        <cargo.servlet.port>8080</cargo.servlet.port>
      </properties>
    </configuration>

Or override it at the command line

mvn -Dcargo.servlet.port=8080 cargo:start

Related Problems and Solutions