Independent extensions:

RSS Feeds


Pages and Blog posts
Mailing list

Definition

How to perform deployments to a remote GlassFish 6.x container

Explanation

All Cargo GlassFish deployers use the GlassFish asadmin behind the scenes, and all of them set the cargo.hostname as the target host.

As a result, all GlassFish Installed Local Deployers can actually be used to perform remote deployments, the main "downside" being that this requires the GlassFish container ZIP file to be downloaded (which can be done transparently using an installer).

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

Installer installer = new ZipURLInstaller(
    "https://download.eclipse.org/ee4j/glassfish/glassfish-6.0.0-RC2.zip",
    "target/downloads", "target/extracts");
installer.install();
 
InstalledLocalContainer container = new GlassFish6xInstalledLocalContainer(
    new GlassFish6xStandaloneConfiguration("target/glassfish6x"));
container.setHome(installer.getHome());

// Set the hostname to a running, remote GlassFish 6.0 instance
// for the GlassFish6xInstalledLocalDeployer to perform a remote deployment
container.getConfiguration.setProperty(GeneralPropertySet.HOSTNAME, "10.0.2.15");

DeployableFactory factory = new DefaultDeployableFactory();
WAR war = factory.createDeployable(container.getId(), "path/to/my.war",
    DeployableType.WAR);
 
Deployer deployer = new GlassFish6xInstalledLocalDeployer(container);
deployer.deploy(war);

Here is an example Maven 3 plugin configuration, where one can use the Maven Artifact Installer:

<plugin>
  <groupId>org.codehaus.cargo</groupId>
  <artifactId>cargo-maven3-plugin</artifactId>
  <version>${cargo.plugin.version}</version>
  <configuration>
    <container>
      <containerId>glassfish6x</containerId>
      <artifactInstaller>
        <groupId>org.glassfish.main.distributions</groupId>
        <artifactId>glassfish</artifactId>
        <version>6.0.0-RC2</version>
      </artifactInstaller>
    </container>
    <configuration>
      <home>${project.build.directory}/glassfish6x-home</home>
      <properties>
        <cargo.hostname>10.0.2.15</cargo.hostname>
        <cargo.servlet.port>8080</cargo.servlet.port>
        <cargo.glassfish.admin.port>4848</cargo.glassfish.admin.port>
      </properties>
    </configuration>
  </configuration>
</plugin>
Copyright 2004-2021. All rights reserved unless otherwise noted.
Click here to read our privacy and cookie policy