Java7
Cargo
Managing deployment to JBoss Application Server using Maven through Cargo plugin
Mar 19th
Application Server: JBoss Application Server 6.0.0 Final http://sourceforge.net/projects/jboss/files/JBoss/JBoss-6.0.0.Final/
Sometime ago, i attempted to deploy a JSF 2.0 web application to the newly released GlassFish Application Server 3.1 through the Maven-Cargo plugin. http://java.sg/managing-deployments-to-application-servers-using-maven-through-cargo-plugin/
Cargo is a truly portable plugin that allows you to deploy to most application server vendors and version.
This code snippet shows the same with JBoss Application Server 6.
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>sg.java</groupId>
<artifactId>web.vms</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>Virtualization Management Console</name>
<url>java.sg</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>${faces.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>${faces.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sun.facelets</groupId>
<artifactId>jsf-facelets</artifactId>
<version>${facelets.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>${primeFaces.version}</version>
</dependency>
<dependency>
<!-- For primefaces theme http://www.primefaces.org/themes.html -->
<groupId>org.primefaces.themes</groupId>
<artifactId>blitzer</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-core-tools-jboss-deployer-5.1-and-onwards</artifactId>
<version>${cargo.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.integration</groupId>
<artifactId>jboss-profileservice-spi</artifactId>
<version>5.1.0.GA</version>
</dependency>
</dependencies>
<build>
<finalName>vms</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<webXml>src/main/webapp/WEB-INF/web.xml</webXml>
</configuration>
</plugin>
<!-- JBoss 6 AS Community -->
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>${cargo.version}</version>
<configuration>
<container>
<containerId>jboss6x</containerId>
<home>${jbossas.home}</home>
</container>
<configuration>
<type>standalone</type>
<home>${jbossas.server}</home>
</configuration>
<deployer>
<type>installed</type>
<deployables>
<deployable>
<groupId>sg.java</groupId>
<artifactId>web.vms</artifactId>
<type>war</type>
<properties>
<context>/vms</context>
</properties>
</deployable>
</deployables>
</deployer>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>java.net</id>
<name>java.net</name>
<url>http://download.java.net/maven/2</url>
</repository>
<repository>
<id>prime-repo</id>
<name>Prime Technology Maven Repository</name>
<url>http://repository.prime.com.tr</url>
<layout>default</layout>
</repository>
<!-- http://community.jboss.org/wiki/MavenGettingStarted-Developers -->
<repository>
<id>jboss-public-repository-group</id>
<name>JBoss Public Repository Group</name>
<url>http://repository.jboss.org/nexus/content/groups/public/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
</repository>
<repository>
<id>codehaus-snapshots</id>
<url>http://ci.repository.codehaus.org/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>codehaus snapshot repository</id>
<url>http://snapshots.repository.codehaus.org/</url>
<releases>
<enabled>true</enabled>
</releases>
</pluginRepository>
</pluginRepositories>
<properties>
<junit.version>4.8.2</junit.version>
<primeFaces.version>2.2.1</primeFaces.version>
<faces.version>2.0.3</faces.version>
<javaee.version>1.0.0.Final</javaee.version>
<facelets.version>1.1.15.B1</facelets.version>
<cargo.version>1.0.6</cargo.version>
<jbossas.home>C:\c\server\jbossas-vms\jboss-6.0.0.Final</jbossas.home>
<jbossas.server>${jbossas.home}\server\default</jbossas.server>
</properties>
</project>
To deploy, simply issue the following command in the same directory as where your pom.xml descriptor is sitting.
$ mvn cargo:deploy
You should see output similar to this:
bash-3.2$ mvn cargo:redeploy
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Virtualization Management Console 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- cargo-maven2-plugin:1.0.6:redeploy (default-cli) @ web.vms ---
[INFO] [talledLocalContainer] Parsed JBoss version = [6.0.0]
[INFO] [stalledLocalDeployer] Undeploying [C:\c\server\jbossas-vms\jboss-6.0.0.Final\server\default/deploy/vms.war]...
[INFO] [stalledLocalDeployer] Deploying [C:\c\development projects\project ejb3.1\ide_workspace\ejb3.1_eclipse_workspace\web.vms\target\vms.war] to [C:\c\server\jbossas-vms\jboss-6.0.0.Final\server\default/deploy]...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.929s
[INFO] Finished at: Sat Mar 19 15:29:44 SGT 2011
[INFO] Final Memory: 6M/150M
[INFO] ------------------------------------------------------------------------
Managing deployment to GlassFish Application Server using Maven through Cargo plugin
Mar 8th
Application Server: GlassFish 3.1 http://glassfish.java.net/downloads/3.1-final.html
It is now a little past sleeping time in Singapore (1:55 am GMT +8:00), but i wanted to deliver this quick “recipe” as soon as i can because i know the guys over at in NY’s probably in their daytime and looking for the last pieces of this maven-cargo puzzle. Just a while ago, i managed to put into a complete Maven project object model descriptor (pom.xml) that manages deployment to GlassFish application server through the use of Cargo-plugin. This is exciting as this is the first time i have tested it with 1 – a helloworld JSF 2.0 web application that i have been working on, 2 – deployment to GlassFish 3.1 worked seamlessly with much success, as guaranteed by Cargo’s 1.0.6′s GA release.
If you have been using Maven to manage dependencies all along, and have been manually deploying to your application server either though copy and paste or its native admin console, perhaps it is a good time to see how the Cargo plugin may work better for you. One advantage of using the Cargo plugin to manage this aspect is that once you are familiar with configuring the project object model descriptor (pom.xml) for one application server (i.e JBoss AS), it is easy to do that for another (i.e. GlassFish), and there is no another learning curve, or perhaps a very small one.
Maybe i should not go into too much detail as the Cargo plugin site provides an overwhelming load of details and i guess what is lacking is perhaps some working examples so here is a pom.xml i am currently using for my JSF 2.0 Helloworld project that is (since a while ago) injected with Cargo plugin configuration that enables it to be deployed to my GlassFish 3.1 application server, you may use this as a sample guide.
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>sg.java</groupId>
<artifactId>web.vms</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>Virtualization Management Console</name>
<url>java.sg</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>${faces.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>${faces.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sun.facelets</groupId>
<artifactId>jsf-facelets</artifactId>
<version>${facelets.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>${primeFaces.version}</version>
</dependency>
<dependency>
<!-- For primefaces theme http://www.primefaces.org/themes.html -->
<groupId>org.primefaces.themes</groupId>
<artifactId>aristo</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>org.glassfish.deployment</groupId>
<artifactId>deployment-client</artifactId>
<version>3.0.1</version>
<scope>runtime</scope>
</dependency>
</dependencies>
<build>
<finalName>vms</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<webXml>src/main/webapp/WEB-INF/web.xml</webXml>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.0.6</version>
<configuration>
<!-- Container configuration -->
<container>
<containerId>glassfish3x</containerId>
<home>C:\c\server\jbossas-vms\glassfish3</home>
</container>
<!-- Configuration to use with the container -->
<configuration>
<type>standalone</type>
<properties>
<cargo.remote.username>admin</cargo.remote.username>
<cargo.remote.password>adminadmin</cargo.remote.password>
<cargo.glassfish.domain.name>domain1</cargo.glassfish.domain.name>
</properties>
</configuration>
<!-- Deployer configuration -->
<deployer>
<type>installed</type>
<deployables>
<deployable>
<groupId>sg.java</groupId>
<artifactId>web.vms</artifactId>
<type>war</type>
<properties>
<context>/vms</context>
</properties>
</deployable>
</deployables>
</deployer>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>java.net</id>
<name>java.net</name>
<url>http://download.java.net/maven/2</url>
</repository>
<repository>
<id>prime-repo</id>
<name>Prime Technology Maven Repository</name>
<url>http://repository.prime.com.tr</url>
<layout>default</layout>
</repository>
<!-- http://community.jboss.org/wiki/MavenGettingStarted-Developers -->
<repository>
<id>jboss-public-repository-group</id>
<name>JBoss Public Repository Group</name>
<url>http://repository.jboss.org/nexus/content/groups/public/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
</repository>
<repository>
<id>codehaus-snapshots</id>
<url>http://ci.repository.codehaus.org/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>codehaus snapshot repository</id>
<url>http://snapshots.repository.codehaus.org/</url>
<releases>
<enabled>true</enabled>
</releases>
</pluginRepository>
</pluginRepositories>
<properties>
<junit.version>4.8.2</junit.version>
<primeFaces.version>2.2</primeFaces.version>
<faces.version>2.0.3</faces.version>
<javaee.version>1.0.0.Final</javaee.version>
<facelets.version>1.1.15.B1</facelets.version>
</properties>
</project>
To deploy, simply issue the following command in the same directory as where your pom.xml descriptor is sitting.
$ mvn cargo:deploy
Or issue a mvn:redeploy if this is a re-deployment
$ mvn cargo:redeploy
You should see something similar to this:
bash-3.2$ mvn cargo:redeploy
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Virtualization Management Console 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- cargo-maven2-plugin:1.0.6:redeploy (default-cli) @ web.vms ---
[INFO] [talledLocalContainer] Deprecated syntax, instead use:
[INFO] [talledLocalContainer] asadmin --interactive=false --port 4848 --user admin --passwordfile C:\Users\Oh Chin Boon\cargo\conf\password.properties deploy [options] ...
[INFO] [talledLocalContainer] Application deployed with name vms.
[INFO] [talledLocalContainer] Command deploy executed successfully.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.785s
[INFO] Finished at: Tue Mar 08 01:42:27 SGT 2011
[INFO] Final Memory: 7M/150M
[INFO] ------------------------------------------------------------------------
If you are having trouble deploying due to password failure and you are very certain that the password you have provided in the pom.xml descriptor is correct, then delete the physical password.properties file which in my case is located in “C:\Users\Oh Chin Boon\cargo\conf\”.
Cheers.
Reference
http://cargo.codehaus.org/Glassfish+3.x (If you are not deploying to Glassfish, then choose your targeted application server configuration accordingly)