Over a million developers have joined DZone.

How to Deploy a Custom System Bundle

DZone's Guide to

How to Deploy a Custom System Bundle

A good developer will create their own framework to be extended by interface OSGI bundles for easy development and for code reusability. Customization is key!

· Integration Zone ·
Free Resource

WSO2 is the only open source vendor to be named a leader in The Forrester Wave™: API Management Solutions, Q4 2018 Report. Download the report now or try out our product for free.

The intention of this blog is to give an idea to those (like me) who suffered from having no or little guidance when engineering an ESB. Before you decide how to start engineering your own ESB, decide on the right ESB tool. This blog makes use of Apache ServiceMix 7.0.0.M1 as an ESB tool, Apache maven 3.3.1 and Apache camel for development.


Deploying Custom OSGI Bundle as System Bundle

Why use system bundle deployment? A good developer will create his or her own framework which offers features like constructors, security, error handling, database connectivity, third-party service connectivity, multithreading ability, clustering, high availability, extensibility, etc., to be extended by interface OSGI bundles for easy development and for code reusability. Apache ServiceMix activates bundles and context when deployed one in a deploy folder, but will do another if it's a system feature. The difference is that former deployments will be repetitive for each restart of ServiceMix/Karaf; the later method is just one-time.

The framework bundle shouldn't be restarted each and every time the ServiceMix starts. Otherwise, it isn't customized. A framework should be installed as a feature in ServiceMix only once and should be customized by interface bundles. Hence, a custom OSGI framework bundle should be deployed as system bundle.

Now, how do we deploy it as system bundle? Here are the steps.

  1. Download Apache ServiceMix.

  2. Extract the downloaded ZIP into a working directory.

  3. Set the below variables in System’s Environment Variables:



  4. Edit $KARAF_HOME/etc/org.ops4j.pax.url.mvn.cfg to change the location of Maven’s settings.xml as ServiceMix refers to Maven’s default local repository path ${user.home}/.m2/settings.xml.

    • Change the value of the config parameter org.ops4j.pax.url.mvn.settings=<M2_HOME>/conf/settings.xml. 

  5. Create the below Karaf system folder:

    •  $KARAF_HOME/system/<groupid>/<artifactid>/<version>Example:

  6. group id: com.test.base
    artifact id: my-framework
    version: 0.0.1-SNAPSHOT

    Folder structure to be created:


  7. Paste the Maven-built framework.

  8. Include this entry in $KARAF_HOME/etc/startup.properties: 

    • mvn\:com.test.base/my-framework/0.0.1-SNAPSHOT = 16.

  9. Start $KARAF_HOME/bin/servicemix.bat. 

  10. If any dependency of system bundle deployed throws an error, install those features. Examples:

    • features:addurl mvn:io.hawt/hawtio-karaf/1.2.3/xml/features.

    • features:install hawtio-core.

    • features:install camel-groovy.

That's it! Now, your preconfigured ESB is ready. You can create your interface that extends the OSGI system bundle and deploy it in ServiceMix for servicing requests.

IAM is now more than a security project. It’s an enabler for an integration agile enterprise. If you’re currently evaluating an identity solution or exploring IAM, join this webinar.

esb ,apache servicemix ,maven ,bundles ,service requests ,integration ,tutorial

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}