Versions Compared

Key

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

Definition

Excerpt

Deployables are archives (WAR, EAR, etc) that can be deployed in the container

Explanation

A Deployable class is a wrapper class around a physical archive. Deployable are constructed by directly instantiating them (e.g. new WAR(...) or new TomcatWAR(...)) or by using a DeployableFactory (e.g. DefaultDeployableFactory). There are 2 generic deployable classes:

...

Deploying a WAR in Tomcat 5.x:

Code Block

Container container = new Tomcat5xContainer(
    new CatalinaStandalineConfiguration("target/tomcat5x"));
container.setHome("c:/apps/tomcat-5.0.29");

WAR war = new WAR("path/to/my.war");

[...]

Example using the Generic API

Code Block

[...]

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

...

Statically deploying a WAR in Tomcat 5.x:

Code Block
xml
xml

<cargo containerId="tomcat5x" home="c:/apps/tomcat-5.0.29" action="start">
  <configuration>
    <war warfile="path/to/my.war"/>
  </configuration>
</cargo>

Example using the Maven 2 plugin

Code Block
xml
xml

<dependencies>
  [...]
  <dependency>
    <groupId>my.war.groupId</groupId>
    <artifactId>my-war</artifactId>
    <version>1.0.0</version>
    <packaging>war</packaging>
  </dependency>
  [...]
</dependencies>

[...]

<plugins>
  [...]

  <plugin>
    <groupId>org.codehaus.cargo</groupId>
    <artifactId>cargo-maven2-plugin</artifactId>
    <configuration>
      <container>
        [...]
      </container>
      <configuration>
        <type>standalone</type>
        [...]
      </configuration>
 <deployables>     <deployables>
     <deployable>   <deployable>
          <groupId>my.war.groupId</groupId>
            <artifactId>my-war</artifactId>
            <type>war</type>
          </deployable>
        </deployables>
      </configuration>
    </configuration>
  </plugin>
</plugins>
Note
titleCareful with the <configuration> elements!

The Maven2 plugin has two <configuration> elements:

  • The first (outer) one is the plugin's configuration
  • The second (inner) one is the container's configuration

The <deployables> element should be in the inner <configuration> element.