How to perform deployments to a remote GlassFish 6.x and later containers, as well as to recent versions of Payara


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

As a result, all GlassFish and payara Installed Local Deployers can actually be used to perform remote deployments, the main "downside" being that this requires the GlassFish / Payara 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(
    "target/downloads", "target/extracts");
InstalledLocalContainer container = new GlassFish6xInstalledLocalContainer(
    new GlassFish6xStandaloneConfiguration("target/glassfish6x"));

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

// Instruct the GlassFish asadmin to upload the file to the remote server
    GlassFishPropertySet.DEPLOY_ARG_PREFIX + "remoteUpload", "--upload=true");

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

// Create dummy local configuration and deploy remotely
Deployer deployer = new GlassFish6xInstalledLocalDeployer(container);

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


Please note that the above deployer requires its "dummy" local configuration to exist. You hence need to run it with:

mvn cargo:configure cargo:deploy
Copyright 2004-2024. All rights reserved unless otherwise noted.
Click here to read our privacy and cookie policy