Building Your Equinox OSGi Application Server – Part 3

Building Your Equinox OSGi Application Server – Part 3

In part 2 of this blog series, I described how to use Equinox p2 to install a new feature into a running Equinox application server. Rather than do this install at runtime via the OSGi console, many times it’s desirable to add bundles to an application server statically at build time rather than at runtime.  For example, this is usually the case when adding libraries for your web application to use. These libraries are sometimes created by others and sometimes created by you.

This post will go through a simple example of how to add your own bundles to your Equinox application at build time.

First, let’s return to the workspace that we setup as described in the first post in this series.  Here’s what the workspace should look like after completing steps 1-4 of the first post:


To add sets of bundles to the target application server, we create a new feature for grouping the bundles.  A feature project is created through the new project wizard via menu selections New Project->Other…->Plugin Development->Feature Project.  I’ve created a new empty feature called com.mycompany.myappserverfeature, but it can be called anything you like:


Then choose the Plug-ins (otherwise known as bundles) tab in the feature editor and you can add bundles to be included in your new feature.  The bundles that appear in the dialog when selecting Add… will include all the bundles in your workspace, as well as all bundles currently included in your target platform.  For a description of how to add to your target platform, and an explanation of what you can do with the target platform since Eclipse 3.5 please see the Improved Target Platform Management blog post.

I’ve also added some bundles in my target platform that support doing ECF remote services with the r-OSGi provider.   This enables support for remote OSGi services between application servers (i.e., having one server call a remote OSGi service exposed by another server).


After adding the bundles you wish to include, save the changes to your feature and then add your new feature to the equinox-milli.product. Features can be added to the equinox-milli.product on the Dependencies tab of the equinox-milli.product editor.

Here’s the Feature Selection dialog that appears when you select Add… on the Dependencies tab:


And then you will see your com.mycompany.myappserverfeature listed as part of the equinox-milli.product:


Save the changes to the equinox-milli.product and then you can go to product editor Overview tab, select the Eclipse Product export wizard (in lower right of Overview tab) to display the export wizard dialog:


You can now click Finish and do exactly the same things as described in steps 6, 7, 8, 9 in the original post to create a zip file (e.g., named, rename it to myappserver.war and then hot deploy the new war file to your servlet container of choice to run it.

Once running, at the osgi> prompt you can convince yourself that the added bundles are now present in your application server by typing ss and looking for the bundles added by your feature in the resulting list:


As you can see, these bundles are in place and ready to use from within your web applications!

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

    I have to do these steps (especially the rename job) every time I changed some Java code in one of my bundles?

  • Posted at 22:40, 2009-08-20

    Scott, can you file an enhancement request for this? I believe it just requires me fixing the validation code in PDE.

    I believe right now, you aren’t allowed to change the extension from “.zip” … correct?

  • Andrea Zoppello
    Posted at 16:39, 2009-09-03

    Hi Scott,

    Very nice series…. it help a lot to install and deploy the servlet bridge features.

    BTW the approach used in the bridge.war file downlodable from equinox wiki pages use a slightly different approach:

    1) The “simple configurator” is not used there
    2) In the bridge.war from the wiki pages the “extension bundle” is automatically generated…. why did you choose
    a different approach???

    BTW i’m also interested too to know how this works under the hood, in particular to understand
    how this happens and the detailed steps… from code development to deployments…

    Just my two cents but one of the problems with the servlet-bridge is that it use ( in my opinion ) a confusing
    packaging schema… so it’s very hard to understand which is the stuff that go in webapp, and which is the equinox
    counterpart and how to work…

    I’m writing these because i’m trying to implement a solution where i could register in my webapp an an object that let me to call osgi services installed in equinox that are not “servlets” but services that implements my interface “org.myapp.IMyInterface” for example and i’m encountering problems in developments and to setup the build and deployment environment to do that…


  • Andres
    Posted at 03:45, 2010-01-26


    Thanks for the tutorial. I tried to follow the steps in part 3, created my own feature and added a single plugin. Added the feature to the product, and exported the product. I can see my plugin in the plugins directory and my feature in the features directory. However, when I start tomcat I can’t see my plugin when i run “ss” from the osgi prompt. Is there anyway to get more debuging?

    Thanks a lot,


  • Andres
    Posted at 04:05, 2010-01-26

    Ok, why do you always have to stumble with the answer 5 minutes after posting a question that makes you look stupid? Any way, I was deploying in Tomcat, and my webapp was cached under temp. Clearing the temp directory made my bundles available.

  • Luis Carlos Moreira da Costa
    Posted at 19:23, 2010-04-08

    Thanks for tutorial!

  • arez
    Posted at 16:06, 2011-11-10

    Very interesting. Is there a possbility to add start level and add auto start features the way it is done in PDE?