DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
  1. DZone
  2. Coding
  3. Java
  4. How to Deploy a Custom System Bundle

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!

Balaji Kannan user avatar by
Balaji Kannan
·
Feb. 28, 17 · Tutorial
Like (1)
Save
Tweet
Share
4.74K Views

Join the DZone community and get the full member experience.

Join 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.

Prerequisites

  • Apache Maven installation.

  • JDK 1.7 or above.

  • Custom OSGI bundle to be deployed as system bundle.

  • Third-party installation to a local Maven repo.

  • Apache ServiceMix 7.0.0.M1 or above.

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:

    • KARAF_DEBUG=TRUE.

    • KARAF_HOME=<SERVICEMIX_HOME>.

  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:

     $KARAF_HOME/system/com/test/base/my-framework/0.0.1-SNAPSHOT 

  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.

Apache Maven Apache ServiceMix

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Create Spider Chart With ReactJS
  • Is DevOps Dead?
  • What Is API-First?
  • Key Elements of Site Reliability Engineering (SRE)

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: