Building Your Equinox OSGi Application Server – Part 2

Building Your Equinox OSGi Application Server – Part 2

In my previous post, I described how to easily build an Equinox-based web application server that can be run on any servlet container. Note that in the previous post I had these instructions for completing the export wizard dialog

d) The Generate metadata repository should be unchecked

If using p2 (as in this post), this is incorrect.  It should say

d) The Generate metadata repository should be checked (to include p2 metadata)

I’ve updated this documentation in the original posting.

Once your p2-enabled app server is running, you can do some really cool things with it.  For example, since p2 is available, you can dynamically install new components into your running application server.  Here’s the OSGi console help output (part of it anyway):


Notice the Provisioning Commands text.  These are console commands enabled by the presence of p2 that allow you to do common provisioning operations like installing new components.  In this blog entry, I’ll show how to install a version of the Knoplerfish httpconsole, but the same approach applies to software available from other p2 repositories.  In other posts, the EclipseSource team will show how to do this hot deployment into a running server for:

First, one must add the metadata and artifact repository URIs using the provaddrepo and provaddartifactrepo commands:


Notice the provlg command, which lists the p2 groups available in the newly added repositories (in this case, the Knopplerfish httpconsole v2.0.0).  Now, issue the provinstall command with the feature group and version… wait a few seconds and you should see the install complete message


Then issue the confapply command (this command applies the new bundle configuration to the currently running platform):


Now, you can see the new bundle installed via the short status (ss) command:


To start the httpconsole bundle (and activate the servlet that it runs) just type start 50.

At this point, you can open a web browser, and point it at your Equinox application server now running the httpconsole at http://localhost:8080/myappserver/console and magic…your application server is now running the Knoplerfish httpconsole servlet, which provides a web interface to the list of running bundles:


Just for fun, you can stop the httpconsole with stop 50 and the servlet will no longer respond


You can start it back up, and then the servlet will be running again. This makes a nice demo for people that have to manage the install and update of new components into a running application server. In future posts, I’ll show how to add features to your application server statically (during the build, rather than at runtime) as well as how to use ECF remote services to manage a running application server without having to use the OSGi console.


  • Kim Moir
    Posted at 10:33 pm, August 17, 2009

    Very interesting! Great post.

  • Frederic
    Posted at 12:00 pm, August 18, 2009

    What about provisioning thru Maven repos ?

  • Udo
    Posted at 9:46 am, August 20, 2009

    Where do I get the knopflerfish repository from? How do I install it?

  • Santosh B
    Posted at 2:21 am, August 28, 2009

    knoplerfish rep details is missing and as you said in the previous comment changes in the existing servlet.

  • Posted at 3:25 pm, August 28, 2009

    Hi Santosh. For the moment, I don’t feel comfortable redistributing the changes that I made to the knoplerfish servlet (just some absolute to relative path changes), because I haven’t gotten any approval for doing this from the knopplerfish folks. So for the moment, I’ll just direct you to to get the original knopflerfish code…and I will be happy to guide you through the necessary changes. And I will try to get a hold of the knoplerfish committers and offer to contribute the changes back.

  • Posted at 8:46 pm, November 6, 2009

    Is there a way to accomplish the same console-based provisioning steps using the p2 director application? That would allow for finer-grained control + uninstalls.

  • Bill Nelson
    Posted at 8:06 pm, December 2, 2009

    Excellent tutorial! Thank you. Quick question, is it necessary to run Equinox OSGi in a servlet container application? We have developed an application that simply moves files around using Spring Integration and we would prefer not using Spring dm, Tomcat, etc. Can it be done?

  • Posted at 12:50 am, April 12, 2010

    Great article! Thanks.
    I guess you changed the code in Activator. Anyway if I just change absolute path to relative I get an exception when I try to start the bundle. Id be very gratefull if you can send me your corrections.