Howto use Maven Cargo Plugin to deploy a Web Application Bundle (WAB, OSGI + JavaEE) into Glassfish 3.x

1.1k views Asked by At

I'm trying to use the Maven Cargo Plugin to deploy a set of OSGI bundles and an hybrid application .war (Webapplication with Restservice which uses OSGI) also called a Web Application Bundle (or WAB) (e.g. see https://glassfish.java.net/public/GF-OSGi-Features.pdf).

Deploying of OSGI bundles into a Glassfish 3.1.x works fine, but I haven't found a way to deploy the Web Application Bundle.

It's packaging is "war", but I have to deploy it as OSGI bundle. So how can I tell this the Cargo Plugin?

The maven configuration I tried to use:

  <plugin>
    <groupId>org.codehaus.cargo</groupId>
    <artifactId>cargo-maven2-plugin</artifactId>
    <version>1.4.0</version>
    <configuration>
      <wait>false</wait>

      <container>
        <containerId>glassfish3x</containerId>
        <home>${glassfish.home}</home>
        <type>installed</type>
      </container>
      <configuration>
        <type>existing</type>
        <home>${glassfish.home}</home>
        <properties>
          <cargo.hostname>localhost</cargo.hostname>
          <cargo.rmi.port>4848</cargo.rmi.port>
          <cargo.domain.name>${glassfish.domain}</cargo.domain.name>
        </properties>
      </configuration>
      <deployables>
        <deployable>
          <groupId>com.acme.rest</groupId>
          <artifactId>rest-api</artifactId>
          <type>bundle</type>
        </deployable>
      </deployables>
    </configuration>
  </plugin>

But the following error shows up:

[ERROR] Failed to execute goal org.codehaus.cargo:cargo-maven2-plugin:1.4.0:redeploy (default-cli) on project rest-api: Artifact [com.acme.rest:rest-api:bundle] is not a dependency of the project. -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.cargo:cargo-maven2-plugin:1.4.0:redeploy (default-cli) on project rest-api: Artifact [com.acme.rest:rest-api:bundle] is not a dependency of the project.

Deploying as component type "web" works, but then I can't use the OSGI bundles...

Does anybody have experience with deploying Web Application Bundle and OSGI bundles?

3

There are 3 answers

1
Sahoo On

I don't know about cargo plugin, but to deploy a wab using asadmin client, one has to pass a --type=osgi option as shown below:

asadmin deploy --type=osgi foo.war

So, see if you can configure cargo plugin to pass this option.

Sahoo

0
Snekse On

Try using version 1.4.7 which added support for sending asadmin params in conjunction with the param that @Sahoo mentioned.

<cargo.glassfish.deploy.arg.1>--type=osgi foo.war</cargo.glassfish.deploy.arg.1>

Allow passing extra parameters for glassfish deployment https://jira.codehaus.org/browse/CARGO-1245

0
Marcos Zolnowski On

The trick is :

<deployable>
  <groupId>com.acme.rest</groupId>
  <artifactId>rest-api</artifactId>
  <type>war</type>
  <implementation>org.codehaus.cargo.container.deployable.Bundle</implementation>
</deployable>

You still have a WAR artifact, but Bundle will trick Cargo to deploy it as OSGi.