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.