Java7
GlassFish
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)
GlassFish 3.1 Web Profile VS Full Profile Distribution
Mar 1st
I am recently foraying into GlassFish server because one of the projects i have seen has gone into production with GlassFish and i am interested to see the full capacity of GlassFish in the equilibrium of enterprise application servers.
[Update March 7, 2011] I was revealed to by my PM that the only reason why the project had gone into production with GlassFish was licensing and SLA agreement with certain vendor (maybe SUN), nothing else. There were in fact some pre-production discussions on using JBoss.
I came across a matrix of web vs full profile distribution of GlassFish from Oracle. I will be doing development for EJB 3.1 and the full JDK 6 web technologies such as JSF 2.0. And hopefully during then i will be able to see more offerings from GlassFish.
Table 1-2 GlassFish Server Full Profile and Web Profile Features
|
* The Full Java EE Platform contains the complete CORBA package. The OMG CORBA v3.0 APIs are available in the Java EE Web Profile.
** Transaction propagation not supported.
Note – Regardless of whether you choose the Full Platform or Web Profile distribution, you can add or removed packages after installation by using the Update Tool or pkg utility. SeeChapter 11, Extending and Updating GlassFish Server, in Oracle GlassFish Server 3.1 Administration Guide for more information.
Reference
http://download.oracle.com/docs/cd/E18930_01/html/821-2427/ggrlg.html