Deploying bundles to JBoss Fuse

JBoss Fuse can hot deploy your OSGi bundles automatically when you drop the JAR files in the InstallDir/deploy directory. When you copy a JAR file in this directory, it will be automatically installed in the runtime and also started. Just the same, if you update or delete the JARs, and the changes are handled automatically.

So let’s say you have packaged a bundle named demo-1.0-SNAPSHOT.jar, you can deploy this bundle by copying it to the Jboss Fuse InstallDir/deploy directory as follows:

$ cp demo-1.0-SNAPSHOT.jar $FUSE_HOME/deploy

Then check from the Karaf console that the Bundle is Active:

JBossFuse:admin@root>osgi:list

. . . . .

[ 321] [Active     ] [Created     ] [       ] [   80] demo (1.0.0.SNAPSHOT)

A better alternative, in case your project is composed of several bundles and needs other features to be installed, is to create a features.xml file which can be hot deployed as well. The following sample features.xml file shows how to create a feature named “fuse-custom-feature” which can be deployed on the Container, bundling JAR files and activating some features:

<features name="fuse-custom-feature"
          xmlns="http://karaf.apache.org/xmlns/features/v1.0.0">

  <repository>mvn:org.apache.camel.karaf/apache-camel/${camel.version}/xml/features</repository>
  <repository>mvn:io.fabric8/fabric8-karaf/${fabric8.version}/xml/features</repository>
  <repository>mvn:org.apache.karaf.assemblies.features/enterprise/${karaf.enterprise.version}/xml/features</repository>

  <feature name="fuse-demo-routes" version="${project.version}" resolver="(obr)">
    <feature version="${camel.version}">camel-blueprint</feature>
    <feature version="${camel.version}">camel-jaxb</feature>
    <feature version="${fabric8.version}">camel-amq</feature>
    <feature>amq</feature>
     

    <bundle>mvn:com.sample.demo/demo-project/1.0.0-SNAPSHOT</bundle>
    <bundle>/opt/jboss/fuse/bundles/commons-dbcp-1.4.jar</bundle>
    <bundle>/opt/jboss/fuse/bundles/h2-1.4.191.jar</bundle>

  </feature>

</features>

Simply deploy the feature file as follows:

$ cp features.xml $FUSE_HOME/deploy
Found the article helpful? if so please follow us on Socials