Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

Cargo supports deploying to an already running container. This feature is called [ Hot Deployment). You call it by using the (cargo:deploy) goal (e.g. mvn cargo:deploy).

Note that you can also do static deployment by simply defining the deployables to deploy in the <configuration> element as shown in the Starting and stopping a container tutorial. In that case the deployables will be deployed before the container starts.

We haven't finished implementing Deployers for all containers yet. Please check if your favorite container has it implemented. If not you'll need to deploy your deployables by defining them in a standalone local configuration as shown in the Starting and stopping a container use case.
Info
titleNot all containers have a Deployer implemented
Note
titleNo need to deploy if you are using Cargo to start your container

If you are using Cargo for starting your container, Cargo will actually be doing a static deployment of all your <deployables> automatically. So, no need to deploy anything manually in that case!

Info
titleAbout WAR contexts

Many containers have their specific files for redefining context roots (Tomcat has context.xml, JBoss has jboss-web.xml, etc.). If your WAR has such a file, the server will most probably use the context root defined in that file instead of the one you specify using the CARGO deployer.

...

Code Block
xml
xml
[...]
<configuration>

  <!-- Container configuration -->
  <container>
    <containerId>resin3x</containerId>
    <home>c:/apps/resin-3.0.9</home> or
    <zipUrlInstaller>
      <url>http://www.caucho.com/download/resin-3.0.9.zip</url>
      <downloadDir>${project.build.directory}/downloads</downloadDir>
      <extractDir>${project.build.directory}/extracts</extractDir>
    </zipUrlInstaller>
  </container>

  <!-- Configuration to use with the container (which will also configure the deployer) -->
  <configuration>
    <type>existing</type>
    <properties>
      [...]
    </properties>
  </configuration>

  <!-- Deployer configuration -->
  <deployer>
    <type>local</type>
  </deployer>

  <!-- Deployables configuration -->
  <deployables>
    <deployable>
      <groupId>war group id</groupId>
      <artifactId>war artifact id</artifactId>
      <type>war</type>
      <properties>
        <context>optional root context</context>
      </properties>
      <pingURL>optional url to ping to know if deployable is done or not</pingURL>
      <pingTimeout>optional timeout to ping (default 20000 milliseconds)</pingTimeout>
    </deployable>
    <deployable>
      <groupId>ear group id</groupId>
      <artifactId>ear artifact id</artifactId>
      <type>ear</type>
      <pingURL>optional url to ping to know if deployable is done or not</pingURL>
      <pingTimeout>optional timeout to ping (default 20000 milliseconds)</pingTimeout>
    </deployable>
    [...]
  </deployables>
</configuration>
[...]

As for the cargo:start goal if your project is a J2EE project then the generated artifact will be automatically added to the list of deployables to deploy.

Using a remote deployer

A remote deployer is a deployer that deploys deployables on a Remote Container (i.e. a container that is running and that has been started externally from Cargo). Thus you'll need to use an id for a remote container in <containerId> and a Runtime Configuration.

Info
titleNot all containers have a remote Deployer implemented

We haven't finished implementing remote Deployers for all containers yet. Please check if your favorite container has it implemented. If not you'll need to deploy your deployables by defining them in a standalone local configuration as shown in the starting and stopping a container use case or the Cargo Daemon.

Example of doing a remote deploy using a runtime configuration:

Code Block
xml
xml
[...]
<configuration>

  <!-- Container configuration -->
  <container>
    <containerId>tomcat6x</containerId>
    <type>remote</type>
  </container>

  <!-- Configuration to use with the container (which will also configure the deployer) -->
  <configuration>
    <type>runtime</type>
    <properties>
      <cargo.remote.username>username</cargo.remote.username>
      <cargo.remote.password>password</cargo.remote.password>
    </properties>
  </configuration>

  <deployer><!-- Deployables configuration -->
 <type>remote</type>
  </deployer>

  <deployables>
    <deployable>
      <groupId>war group id</groupId>
      <artifactId>war artifact id</artifactId>
      <type>war</type>
      <properties>
        <context>optional root context</context>
      </properties>
      <pingURL>optional url to ping to know if deployable is done or not</pingURL>
      <pingTimeout>optional timeout to ping (default 20000 milliseconds)</pingTimeout>
    </deployable>
    [...]
  </deployables>

</configuration>
[...]

...

This functionality is available in the Java API, ANT tasks and Maven2/Maven3 plugin.