Question

I have not been able to get a successful Maven pom.xml configuration to start JBoss AS 7, deploy a war artifact, and have it wait until the artifact has been successfully deployed before starting to run integration tests.

I've already consulted...

I want to use an installed (and pre-configured) JBoss AS 7 container. I do not want to have it up-and-running all the time. I want to start it, run some tests, and shut it down.

My environment:

  • cargo-maven2-plugin 1.3.1
  • jboss-as-7.1.1.Final
  • maven-failsafe-plugin 2.12.4

Here's what I have for Failsafe config...

        <plugin>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>${maven-failsafe-plugin.version}</version>
            <configuration>
                <forkMode>once</forkMode>
                <argLine>-javaagent:"${settings.localRepository}/org/springframework/spring-instrument/${spring.framework.version}/spring-instrument-${spring.framework.version}.jar"</argLine>
                <useSystemClassLoader>true</useSystemClassLoader>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>integration-test</goal>
                        <!-- Uncomment the line below if you want the build to fail when any integration test fails -->
                        <!-- <goal>verify</goal> -->
                    </goals>
                </execution>
            </executions>
        </plugin>

Here's what I have for Cargo config...

                <plugin>
                    <groupId>org.codehaus.cargo</groupId>
                    <artifactId>cargo-maven2-plugin</artifactId>
                    <version>${cargo-maven2-plugin.version}</version>
                    <configuration>
                        <container>
                            <containerId>jboss71x</containerId>
                            <type>installed</type>
                            <home>${jboss71x.home}</home>
                            <output>${project.build.directory}/jboss71x/container.log</output>
                            <append>false</append>
                            <log>${project.build.directory}/jboss71x/cargo.log</log>
                        </container>
                        <configuration>
                            <type>standalone</type>
                            <home>${project.build.directory}/jboss71x/container</home>
                            <properties>
                                <cargo.jboss.configuration>default</cargo.jboss.configuration>
                                <cargo.rmi.port>1099</cargo.rmi.port>
                                <cargo.jvmargs>${servlet.container.jvmargs}</cargo.jvmargs>
                                <cargo.logging>high</cargo.logging>
                                <cargo.servlet.port>8080</cargo.servlet.port>
                            </properties>
                        </configuration>
                        <deployer>
                            <type>installed</type>
                            <deployables>
                                <deployable>
                                    <groupId>${project.groupId}</groupId>
                                    <artifactId>${project.artifactId}</artifactId>
                                    <type>war</type>
                                    <properties>
                                        <context>/ws</context>
                                    </properties>
                                    <pingURL>http://localhost:8080/ws/services</pingURL>
                                    <pingTimeout>30000</pingTimeout>
                                </deployable>
                            </deployables>
                        </deployer>
                    </configuration>
                    <!-- http://navinpeiris.com/2011/08/22/running-integrationacceptance-tests-in-jboss-7-using-cargo/ -->
                    <executions>
                        <execution>
                            <id>start-container</id>
                            <phase>pre-integration-test</phase>
                            <goals>
                                <goal>start</goal>
                                <goal>deploy</goal>
                            </goals>
                        </execution>
                        <execution>
                            <id>stop-container</id>
                            <phase>post-integration-test</phase>
                            <goals>
                                <goal>stop</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>

The above config works great when I want to manually startup the container with mvn clean package cargo:run. But it does not achieve the desired effect during CI builds with mvn clean integration-test.

Hints? Suggestions welcomed.

Was it helpful?

Solution

The configuration above does work!

I had to restart my shell then re-build my project. I do get a deprecation warning on start and stop of the container, but that's a small worry.

[INFO] Building war: D:\workspaces\alstom-grid\Projects\SPP\SPP-MUI\spp-im-mui-ws\target\spp-im-mui-ws-1.0-SNAPSHOT.war
[INFO]
[INFO] --- cargo-maven2-plugin:1.3.1:start (start-container) @ spp-im-mui-ws ---
[WARNING] The <deployables> element under the <deployer> element is deprecated. Please use <deployables> under the plugin <configuration> instead.
[WARNING] The <deployables> element under the <deployer> element is deprecated. Please use <deployables> under the plugin <configuration> instead.
[WARNING] The <deployables> element under the <deployer> element is deprecated. Please use <deployables> under the plugin <configuration> instead.
[INFO]
[INFO] --- maven-failsafe-plugin:2.12.4:integration-test (default) @ spp-im-mui-ws ---
[INFO] Failsafe report directory: D:\workspaces\alstom-grid\Projects\SPP\SPP-MUI\spp-im-mui-ws\target\failsafe-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running org.spp.im.mui.jaxws.client.test.VirtualWebServiceClientITCase
Tests run: 1, Failures: 0, Errors: 0, Skipped: 1, Time elapsed: 0.032 sec

Results :

Tests run: 1, Failures: 0, Errors: 0, Skipped: 1

[INFO]
[INFO] --- cargo-maven2-plugin:1.3.1:stop (stop-container) @ spp-im-mui-ws ---
[WARNING] The <deployables> element under the <deployer> element is deprecated. Please use <deployables> under the plugin <configuration> instead.
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ spp-im-mui-ws ---
[INFO] Installing D:\workspaces\alstom-grid\Projects\SPP\SPP-MUI\spp-im-mui-ws\target\spp-im-mui-ws-1.0-SNAPSHOT.war to C:\.m2\repository\org\spp\im\mui\spp-im-mui-ws\1.0-SNAPSHOT\spp-im-mui-ws-1.0-SNAPSHOT.war

[INFO] Installing D:\workspaces\alstom-grid\Projects\SPP\SPP-MUI\spp-im-mui-ws\pom.xml to C:\.m2\repository\org\spp\im\mui\spp-im-mui-ws\1.0-SNAPSHOT\spp-im-mui-ws-1.0-SNAPSHOT.pom

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1:16.016s
[INFO] Finished at: Wed Nov 28 11:51:39 PST 2012
[INFO] Final Memory: 14M/256M
[INFO] ------------------------------------------------------------------------

OTHER TIPS

As I had the same problem, I want to add some explanation what is needed for this to work.

Notice the ping attributes in the deployable section. Cargo will repeatedly call the given URL for availability before continuing, but only until the timeout is reached.

 <deployable>
   <groupId>${project.groupId}</groupId>
   <artifactId>${project.artifactId}</artifactId>
   <type>war</type>
   <properties>
     <context>/example-app</context>
   </properties>
   <pingURL>http://localhost:8080/example-app/ping</pingURL>
   <pingTimeout>30000</pingTimeout>
 </deployable>

To make your application pingable you have to provide an ping endpoint. You could use JAX-RS with RestEasy for an easy implementation.

@Path("/ping")
public class PingResourceImpl {

    @GET
    @PermitAll // optional. Is needed if you protected your ressources f.e. with a SecurityInterceptor.
    public Response ping() {
        return Response.ok().build();
    }
}

Make sure you configure the servlet-mapping correctly.

<servlet>
    <servlet-name>Resteasy</servlet-name>
    <servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>Resteasy</servlet-name>
    <url-pattern>/ping</url-pattern>
</servlet-mapping>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top