This page last changed on Jan 17, 2011 by alitokmen.

Definition

JSR88-compliant containers support

Explanation

Cargo supports JSR 88: J2EE Application Deployment API, allowing it to be used with any JSR88-compliant container.

The core functionality is implemented by the o.c.c.container.spi.deployer.AbstractJsr88Deployer class (a Deployer implementation), which acts as a proxy to the JSR88 DeploymentManager.

GlassFish

The Glassfish 3.x remote container uses the JSR-88 API. For the connection to succeed, the following JARs need to be in the container classpath or in the current Java Thread's context classloader:

  • deployment-client.jar and its dependencies; which seem to be:
    • admin-cli.jar
    • auto-depends.jar
    • common-util.jar
    • glassfish-api.jar
    • deployment-common.jar
    • hk2-core.jar

Here is an example code for the users of the Java API:

List<URL> urls = new ArrayList<URL>();

// Add many libraries from GlassFish
for (File jar : new File(this.localContainer.getHome(), "glassfish/modules").listFiles())
{
    if (jar.isFile())
    {
        urls.add(jar.toURI().toURL());
    }
}

// Create a ClassLoader contaning all these JARs
URL[] urlsArray = new URL[urls.size()];
urlsArray = urls.toArray(urlsArray);
URLClassLoader classLoader = new URLClassLoader(urlsArray, Thread.currentThread().getContextClassLoader());
Thread.currentThread().setContextClassLoader(classLoader);

// Now, create the GlassFish Remote container
...

Here is an example Maven2 plugin configuration:

<repositories>
  <repository>
     <id>glassfish</id>
     <url>http://download.java.net/maven/glassfish</url>
  </repository>
</repositories>

...

<plugin>
  <groupId>org.codehaus.cargo</groupId>
  <artifactId>cargo-maven2-plugin</artifactId>
  <version>${cargo.plugin.version}</version>
  <configuration>
    <container>
      <containerId>glassfish3x</containerId>
      <type>remote</type>
    </container>
    <configuration>
      <type>runtime</type>
      <properties>
        <cargo.hostname>virtualbox-xp</cargo.hostname>
        <cargo.rmi.port>4848</cargo.rmi.port>
      </properties>
    </configuration>
  </configuration>
  <dependencies>
    <dependency>
      <groupId>org.glassfish.deployment</groupId>
      <artifactId>deployment-client</artifactId>
      <version>3.0.1</version>
    </dependency>
  </dependencies>
</plugin>
Document generated by Confluence on Feb 24, 2011 19:55