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 https://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 22:33, 2009-08-17

    Very interesting! Great post.

  • Frederic
    Posted at 12:00, 2009-08-18

    What about provisioning thru Maven repos ?

  • Udo
    Posted at 09:46, 2009-08-20

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

  • Santosh B
    Posted at 02:21, 2009-08-28

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

  • Posted at 15:25, 2009-08-28

    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 20:46, 2009-11-06

    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 20:06, 2009-12-02

    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 00:50, 2010-04-12

    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.