As of CARGO 1.0.3, the way CARGO supports remote deployments Based on the JBoss Application Server has drastically evolved. This document explains how to configure this support.You can version of JBoss / WildFly you are using, please use the quick links below to directly fo go to the chapter regarding the JBoss version you're targetingassociated chapter:
| Anchor | ||
|---|---|---|
|
JBoss 4.0.x and 4.2.x
...
Here is an example code for the users of the Java API:
Code Block
java List<URL> urls = new ArrayList<URL>(); // Add many libraries from JBOSS_HOME for (File jar : new File(this.localContainer.getHome(), "lib").listFiles()) { if (jar.isFile()) { urls.add(jar.toURI().toURL()); } } for (File jar : new File(this.localContainer.getHome(), "common/lib").listFiles()) { if (jar.isFile()) { urls.add(jar.toURI().toURL()); } } // Create a ClassLoader contaning all these JARs URL[] urlsArray = new URL[urls.size()]; urlsArray = urls.toArray(urlsArray); URLClassLoader classLoader = new URLClassLoader(urlsArray, this.getClass().getClassLoader()); Thread.currentThread().setContextClassLoader(classLoader); // Now, create the JBoss Remote container ...
Here is an example Maven2 plugin configuration:
Code Block
xml <!-- <pluginRepositories> <pluginRepository> <id>jboss</id> <url>http Some transitive dependencies of JBoss artifacts, for example apache-xerces:xml-apis, are only available on the JBoss third party repository. --> <pluginRepositories> <pluginRepository> <id>repository.jboss.org_thirdparty-releases</id> <name>JBoss.org third party releases repository</name> <url>https://repository.jboss.org/nexus/content/groupsrepositories/public/</url> </thirdparty-releases</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>false</enabled> </snapshots> </pluginRepository> <pluginRepository> <id>repository.jboss.org_thirdparty-uploads</id> <name>JBoss.org third party uploads repository</name> <url>https://repository.jboss.org/nexus/content/repositories/thirdparty-uploads</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>false</enabled> </snapshots> </pluginRepository> </pluginRepositories> <repositories> <repository> <id>jboss<<id>repository.jboss.org_thirdparty-releases</id> <url>http<name>JBoss.org third party releases repository</name> <url>https://repository.jboss.org/nexus/content/groupsrepositories/public/</url> </thirdparty-releases</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>false</enabled> </snapshots> </repository> <repository> <id>repository.jboss.org_thirdparty-uploads</id> <name>JBoss.org third party uploads repository</name> <url>https://repository.jboss.org/nexus/content/repositories/thirdparty-uploads</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>false</enabled> </snapshots> </repository> </repositories> ... <plugin> <groupId>org.codehaus.cargo</groupId> <artifactId>cargo-maven2-plugin</artifactId> <version>${cargo.plugin.version}</version> <configuration> <container> <containerId>jboss51x</containerId> <type>remote</type> </container> <configuration> <type>runtime</type> <properties> <cargo.hostname>production27</cargo.hostname> <cargo.rmi.port>11099</cargo.rmi.port> </properties> </configuration> </configuration> <dependencies> <dependency> <groupId>org.jboss.integration</groupId> <artifactId>jboss-profileservice-spi</artifactId> <version>5.1.0.GA</version> </dependency> <dependency> <groupId>org.jboss.jbossas</groupId> <artifactId>jboss-as-client</artifactId> <version>5.1.0.GA</version> <type>pom</type> </dependency> </dependencies> </plugin>
You can also use the CARGO JBoss remote deployer to remotely deploy to JBoss farms versions 5.x and newer. To do so, use these two properties:
cargo.jboss.clustered: iftrue, deployment is done in thefarmdirectorycargo.jboss.configuration: JBoss profile name, default name isdefault
| Anchor | ||
|---|---|---|
|
JBoss 7.0.x and JBoss 7.1.x / WildFly 8.x
The same instructions for JBoss 5.x, 5.1.x and 6.x also apply for JBoss 7.x, 7.1.x and WildFly 8.x, with some differences:
- The JAR files to include are different
- JBoss 7.x uses , 7.1.x and WildFly 8.x use the
cargo.jboss.management.portport.
...
Here is an example code for the users of the Java API:
Code Block
java /** * Add all JARs in a folder in the list of files (recursive). * @param folder Folder to recursively scan. * @param files List containing all files. */ public static void addAllJars(File folder, List<URL> files) throws Exception { if (folder.isDirectory()) { for (File file : folder.listFiles()) { if (file.isFile() && file.getName().endsWith(".jar")) { files.add(file.toURI().toURL()); } else if (file.isDirectory()) { addAllJars(file, files); } } } }
Code Block
java List<URL> urls = new ArrayList<URL>(); // Add many libraries from JBOSS_HOME/modules addAllJars(new File(this.localContainer.getHome(), "modules"), urls); // Create a ClassLoader contaning all these JARs URL[] urlsArray = new URL[urls.size()]; urlsArray = urls.toArray(urlsArray); URLClassLoader classLoader = new URLClassLoader(urlsArray, this.getClass().getClassLoader()); Thread.currentThread().setContextClassLoader(classLoader); // Now, create the JBoss Remote container ...
Here is an example Maven2 plugin configuration:
Code Block
xml <plugin> <groupId>org.codehaus.cargo</groupId> <artifactId>cargo-maven2-plugin</artifactId> <version>${cargo.plugin.version}</version> <configuration> <container> <containerId>jboss7x</containerId> <type>remote</type> </container> <configuration> <type>runtime</type> <properties> <cargo.hostname>production27</cargo.hostname> <cargo.jboss.management.port>19999</cargo.jboss.management.port> </properties> </configuration> </configuration> <dependencies> <dependency> <groupId>org.jboss.as</groupId> <artifactId>jboss-as-controller-client</artifactId> <version>7.0.2.Final</version> </dependency> </dependencies> </plugin>
| Note | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||
On some Linux distributions, remote deployment may fail with an exception like:
That is a known bug, documented in http://community.jboss.org/wiki/WhydoIgetasocketconnectionerrorwhenusingremoteJBossAS and the solution presented on that document is to use a cron job as the root user to fix the file when it gets broken. First, create the correct version of
Important: If possible, enter your hostname with both the "basic" hostname and the fully-qualified domain name. Next, create a script named
Finally, setup a cron job to run this script as often as you like. We recommend every couple of minutes.
Once the | ||||||||||||||
| Note | ||||||||||||||
|
| Code Block |
|---|
[ERROR] Failed to execute goal org.codehaus.cargo:cargo-maven2-plugin:1.1.1:undeploy (redeploy) on project helloservice:
Execution redeploy of goal org.codehaus.cargo:cargo-maven2-plugin:1.1.1:undeploy failed:
Plugin org.codehaus.cargo:cargo-maven2-plugin:1.1.1 or one of its dependencies could not be resolved:
Failed to collect dependencies for org.codehaus.cargo:cargo-maven2-plugin:jar:1.1.1 ():
Failed to read artifact descriptor for trove:trove:jar:2.1.1:
Could not transfer artifact trove:trove:pom:2.1.1 from/to repository.jboss.org (http://repository.jboss.org/maven2/):
Access denied to: http://repository.jboss.org/maven2/trove/trove/2.1.1/trove-2.1.1.pom -> [Help 1]
|
In this case, please define override the JBoss repository by using a mirrorOf declaration in your settings.xml. Example:
<settings>
...
<mirrors>
<mirror>
<id>nexus.repository.jboss.org</id>
<name>JBoss Nexus repository</name>
<url>http://repository.jboss.org/nexus/content/repositories/deprecated/</url>
<mirrorOf>repository.jboss.org</mirrorOf>
</mirror>
</mirrors>
...
</settings>
Please feel free to complain to JBoss if you feel like this is a bad behaviour: https://issues.jboss.org/browse/JBBUILD-682