0

I have a maven (multi-module) project creating some WAR and EAR files for JBoss AS 7.1.x.

For one purpose, I need to deploy one generated EAR file of one module to a fresh JBoss instance and run it, call some REST web service calls against it and stop JBoss. Then I need to package the results of these calls that were written to the database.

Currently, I am trying to use CARGO and the maven ant run plugin to perform this task.

Unfortunately, I cannot get the three (maven, ant run and CARGO) to play together. I don't have the uberjar that is used in the ant examples of cargo. How can I configure the ant run task so that the cargo ant task can create, start, deploy my JBoss? Ideally the one unpacked and configured by the cargo-maven2-plugin in another phase?

Or, is there a better way to achieve my goal of creating the database?

I cannot really use the integration-test phase, as it is executed after the package phase. So, I plan to do it all in compile phase using ant run.

To clarify again:

I need to do the following: start JBoss; deploy a WAR; wait until the startup of the WAR is complete; deploy an EAR file; wait until the EAR has initialized it's database; Call some web services in the implemented by the EAR; stop JBoss; package the database.

All these steps need to be strictly sequential.

Frank
  • 423
  • 1
  • 7
  • 13
  • Why not using the cargo2 maven plugin instead of Antrun ? – khmarbaise Jun 29 '12 at 09:19
  • I need to do the following: start JBoss; deploy a WAR; *wait* until the startup of the WAR is complete; deploy an EAR file; wait until the EAR has initialized it's database; Call some web services in the implemented by the EAR; stop JBoss; package the database. How do I do that with the cargo2-maven plugin? – Frank Jun 29 '12 at 09:36

1 Answers1

1

The following part gives you an impression how to do that. You must change the details. In the given case i use a Tomcat. This will download the Tomcat archive uncompress and install Tomcat locally...

 <plugin>
    <groupId>org.codehaus.cargo</groupId>
    <artifactId>cargo-maven2-plugin</artifactId>
    <configuration>
      <wait>false</wait>
      <container>
        <containerId>tomcat${tomcat.major}x</containerId>
        <zipUrlInstaller>
          <url>http://archive.apache.org/dist/tomcat/tomcat-${tomcat.major}/v${tomcat.version}/bin/apache-tomcat-${tomcat.version}.tar.gz</url>
          <extractDir>${project.build.directory}/extract/</extractDir>
          <downloadDir>${project.build.directory}/download/</downloadDir>
        </zipUrlInstaller>
        <output>${project.build.directory}/tomcat${tomcat.major}x.log</output>
        <log>${project.build.directory}/cargo.log</log>
      </container>
      <configuration>
        <home>${project.build.directory}/tomcat-${tomcat.version}/container</home>
        <properties>
          <cargo.logging>high</cargo.logging>
          <cargo.servlet.port>9080</cargo.servlet.port>
          <cargo.tomcat.ajp.port>9008</cargo.tomcat.ajp.port>
        </properties>
      </configuration>
    </configuration>
    <executions>
      <execution>
        <id>start-container</id>
        <phase>pre-integration-test</phase>
        <goals>
          <goal>start</goal>
          <goal>deploy</goal>
        </goals>
        <configuration>
          <deployer>
            <deployables>
              <deployable>
                <groupId>${project.groupId}</groupId>
                <artifactId>mod-war</artifactId>
                <type>war</type>
                <pingURL>http://localhost:9080/mod-war</pingURL>
                <pingTimeout>30000</pingTimeout>
                <properties>
                  <context>mod-war</context>
                </properties>
              </deployable>
            </deployables>
          </deployer>
        </configuration>
      </execution>
      <execution>
        <id>stop-container</id>
        <phase>post-integration-test</phase>
        <goals>
          <goal>stop</goal>
        </goals>
      </execution>
    </executions>
  </plugin>
khmarbaise
  • 92,914
  • 28
  • 189
  • 235
  • The helped a lot. Now I just need to figure out now to sequence multiple deployments, and all that in the compile phase. – Frank Jun 29 '12 at 11:09
  • In the compile phase? That does not make sense. I would do that into the integration test phase and make a separate module which can be activated by a profile. – khmarbaise Jun 29 '12 at 11:10
  • I need to do it in some phase before package. Which one do you recommend? integration-test definitely does not work, or does it? – Frank Jun 29 '12 at 14:45
  • Why do you need it before package ? This does not make sense, cause before package the EAR etc does not exist...so the best would be to do it in integration-test area cause it is a kind of integration test. I have done several projects with this setup and works perfect. – khmarbaise Jun 29 '12 at 16:55
  • Yes, the EAR does exist, because it is a dependency from another module. This module here only does packaging. No compilation whatsoever. – Frank Dec 13 '12 at 10:10