0

I've got 2 applications (as WAR files) that I need to run on pre-integration phase before executing my test scenarios. I've already configure the maven cargo plugin like this :

<plugin>
                <groupId>org.codehaus.cargo</groupId>
                <artifactId>cargo-maven3-plugin</artifactId>
                <version>1.9.8</version>
                <executions>
                    <execution>
                        <id>neo-start-lanceur</id>
                        <phase>pre-integration-test</phase>
                        <configuration>
                            <container>
                                <containerId>tomcat8x</containerId>
                                <artifactInstaller>
                                    <groupId>org.apache.tomcat</groupId>
                                    <artifactId>tomcat</artifactId>
                                    <version>8.5.9</version>
                                </artifactInstaller>
                            </container>
                            <configuration>
                                <properties>
                                    <cargo.servlet.port>8081</cargo.servlet.port>
                                    <spring.profiles.active>tdc</spring.profiles.active>
                                    <JAVA_OPTS>-Xms512m -Xmx1536m -XX:MinHeapFreeRatio=20 -XX:MaxHeapFreeRatio=70</JAVA_OPTS>
                                </properties>
                                <home>${project.build.directory}/neo-lanceur</home>
                            </configuration>
                            <deployables>
                                <deployable>
                                    <groupId>fr.cnp.neo</groupId>
                                    <artifactId>neo-web-lanceur</artifactId>
                                    <type>war</type>
                                </deployable>
                            </deployables>
                        </configuration>
                        <goals>
                            <goal>start</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>neo-stop-lanceur</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>stop</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>neo-start-webapp</id>
                        <phase>pre-integration-test</phase>
                        <configuration>
                            <container>
                                <containerId>tomcat8x</containerId>
                                <artifactInstaller>
                                    <groupId>org.apache.tomcat</groupId>
                                    <artifactId>tomcat8</artifactId>
                                    <version>8.5.9</version>
                                </artifactInstaller>
                            </container>
                            <configuration>
                                <properties>
                                    <cargo.servlet.port>8080</cargo.servlet.port>
                                    <spring.profiles.active>tdc</spring.profiles.active>-->
                                    <JAVA_OPTS>-Xms512m -Xmx1536m -XX:MinHeapFreeRatio=20 -XX:MaxHeapFreeRatio=70</JAVA_OPTS>
                                </properties>
                                <home>${project.build.directory}/neo-webapp</home>
                                <configfiles>
                                    <configfile>
                                        <file>${project.basedir}/../web/src/test/conf/neo.properties</file>
                                        <todir>webapps/neo-web/WEB-INF</todir>
                                    </configfile>
                                </configfiles>
                            </configuration>
                            <deployables>
                                <deployable>
                                    <groupId>fr.cnp.neo</groupId>
                                    <artifactId>neo-web</artifactId>
                                    <type>war</type>
                                </deployable>
                            </deployables>
                        </configuration>
                        <goals>
                            <goal>start</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>neo-stop-webapp</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>stop</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

But it deployes and run only the first application.

Is it possible to deploy 2 WARs on a single tomcat instance or to create 2 local containers?

Thanks for your help !!

1 Answers1

0

You can deploy both WARs on a single Tomcat instance by placing them into <deployables> section:


                            <deployables>
                                <deployable>
                                    <groupId>fr.cnp.neo</groupId>
                                    <artifactId>neo-web-lanceur</artifactId>
                                    <type>war</type>
                                </deployable>
                                <deployable>
                                    <groupId>fr.cnp.neo</groupId>
                                    <artifactId>neo-web</artifactId>
                                    <type>war</type>
                                </deployable>
                            </deployables>
Karel Suta
  • 179
  • 5
  • Great! it works fine! But I have now troubles with application context names which must be differents. – Aym4983 Dec 14 '21 at 14:43
  • Application context names should be derived from artifact id, at least according to [1] You can specify in explicitly as part of deployable: some-application-context [1] https://codehaus-cargo.github.io/cargo/Maven+3+Plugin+Reference+Guide.html#Maven3PluginReferenceGuide-prop2 – Karel Suta Dec 15 '21 at 17:33