How to deploy applications to WildFly using Cargo

Cargo is a thin wrapper that allows you to manipulate various type of application containers (Java EE and others) in a standard way. In this tutorial we will learn how to use it to deploy applications on WildFly from your pom file.

Cargo provides the following APIs and tools:

  • A Java API to start/stop/configure any of the supported containers.
  • A Java API to (remotely or locally) deploy modules into these containers, be it a server alone, a farm or a cluster.
  • A Java API to parse/create/merge JEE modules.

Let’s see how to use it to deploy an application to WildFly. You will need for that a valid pom.xml which is able to build a JEE module, for example a web application.

In order to use Cargo we will include into the pom.xml file a reference to the Cargo Plugin and the containerId, which in our case is “wildfly12x”:


	<!-- Configuration to use with the container (which will also configure the deployer) -->


In order to deploy your application, simply run the Maven goal:

mvn cargo:deploy

In order to undeploy your application, simply run the Maven goal:

mvn cargo:undeploy

In the above example, we have assumed that Cargo will run against a remote WildFly application server. It is also possible to let Cargo donwload a fresh version of WildFly and deploy the application on the top of it. And you can do that with just one line as follows:

mvn clean verify org.codehaus.cargo:cargo-maven2-plugin:run \
    -Dcargo.maven.containerId=wildfly12x \