Accueil > Equinox ServletBridge > OSGi Equinox in a Servlet Container [step3]

OSGi Equinox in a Servlet Container [step3]

In [step2], we have explained how bridge and sample.http works. We have seen several problems (4 problems) with OSGi Equinox in a Servlet Container. In this article we will fix 2 problems :

  • It may that /sp_redeploy doesn’t work with WTP Web Dynamic Project. I had the problem once, so I will explain more the problem, how fix it and we will understand how WTP deploy the WEB application.
  • when bundle (ex : sample.http2) is developed in the workspace, it use JAR coming from the Eclipse IDE and not from the /bridge/ WEB-INF/WebContent/eclipse/plugins folder. We have seen it can cause problem when bundle is deployed ( in the Import Packages Problem [step2] section). I will explain how we can fix this problem with Target Platform.


You can download which contains following explained projects : Target Platform is used to use bundle JAR from the /bridge/ WEB-INF/WebContent/eclipse/plugins folder and not from the Eclipse IDE. To use it, click on Set As Target Platform.

WTP deployment

I had a problem once after having created and deployed the sample.http2. The sample.http2_1.0.0.jar was correct in my bridge WEB Application, but when I have done /sp_redeploy, the bridge WEB Application used an old version of the sample.http2_1.0.0.jar.

To resolve the problem I had studied how WTP deploy WEB Application and I think it’s important to understand that. When you are using Dynamic Web Module Project (with default configuration and not the external Web Module), WTP works with several folder. Here a scheme which show you the different folder :

This scheme is a screen of my Eclipse workspace folder. In the article I will use ${workspace_loc} to speak about the Eclipse workspace home. You can see that there are three /WEB-INF/eclipse/plugins folder coming from :

  • (A) Bridge Dynamic Web Project : ${workspace_loc}/bridge/ WEB-INF/eclipse/plugins, our WTP Dynamic Web Project.
  • The workspace contains the .metadata which contains the whole Metadata of the Eclipse plugins.
    • (B) WTP Bridge : WTP use this folder to store some Metadata and deploy the WEB Application in the folder ${workspace_loc}/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/bridge. WTP deploy the WEB Application when Tomcat server is started.
    • (C) Tomcat work Bridge : ${workspace_loc}/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/work/Catalina/localhost/bridge which is the Tomcat working folder.

When you go at /sp_redeploy to clean eclipse/plugins JAR, this command take the JAR from the (B) WTP Bridge (wtpwebapps/bridge) and copy it to the (C) Tomcat work Bridge which are the JAR used (and NOT (A) Bridge Dynamic Web Project to (C) Tomcat work Bridge as we can believe).

When I have had a problem with my JAR which was a not good version, (B) WTP Bridge was not synchronized with (A) Bridge Dynamic Web Project (Why? I don’t know). To fix the problem I had to copy/paste the JAR from (A) to (B).

Target Platform

In Import Packages Problem [step2] section we have seen a problem with import packages. This problems comes from that our sample.http2 bundle from the workspace depends on bundle JAR coming from the Eclipse IDE and not from the bridge/WebContent/WEB-INF/eclipse/plugins folder (org.eclipse.osgi.services_3.2*.jar is used):

In this section we will create and configure the Target Platform to use JAR from the bridge/WebContent/WEB-INF/eclipse/plugins (org.eclipse.osgi.services_3.1*.jar is used) :

Target Platform is used to define your whole plugins (different from the Eclipse IDE folder) that you wish used.

Create Target Platform

Here we create the Target Platform with PDE (Plug-in Development Environment). To do that go at menu File/New/Other and Plug-in Development/Target Definition :

Click on Next button. The New Target Definition wizard is displayed. Here, we will create the file in the bridge WEB Application, but you can create it in any folder. To do that :

  • Select the bridge folder.
  • Fill File name filed with « bridge »(in order to create file).
  • Select « Nothing » for Initialize the target definition with to create an empty target definition (none plugins).

Click on Finish button, the Target definition wizard generate a file in the bridge project. Your workspace looks like this :

Here we will add /bridge/WebContent/WEB-INF/eclipse/plugins folder in the target definition to use JAR coming from this folder. To do that, open the, go at definition tab and click on Add… button. The Add Content wizard display. Select Directory node :

Click on Next button and fill Location field with ${workspace_loc}/bridge/WebContent/WEB-INF/eclipse/plugins. ${workspace_loc} is a variable known by Eclipse IDE which is used to retrieve your Eclipse workspace path :

Click on Next button, you will see your plugins :

Click on Finish button.

Install Target Platform

Here we have defined /bridge/WebContent/WEB-INF/eclipse/plugins and you will see in the target definition 11 plugins :

Now we can activate this Target Platform to use plugins in your workspace. To do that click on Set as Target Platform link (on the top right of the This action will re-compile your workspace with the JAR defined in the target definition. You will have compilation problems with javax.servlet package :

Add javax.servlet

Compilation problems with javax.servlet is normal because the Target Platform doesn’t contain the javax.servlet bundle. We will see how bridge can retrieve javax.servlet package although /plugins folder doesn’t contains this bundle (It’s managed with Fragment-Host: system.bundle; extension:=framework (I will explain more that in a futur article))?

In our case we need to import javax.servlet bundle which define HTTP Servlet interface. To manage that we will use the javax.servlet coming from the Eclipse IDE. To do that, open the, go at definition tab and click on Add… button. The Add Content wizard display. Select Directory node :

Click on Next button and fill Location field with ${eclipse_home}. ${eclipse_home} is a variable known by Eclipse IDE which is used to retrieve your the Eclipse home path :

Click on Finish button, contains the (in my case) 726 plugins from the Eclipse IDE and the 11 plugins coming from bridge WEB Application :

Now we must filter the 726 plugins from the Eclipse IDE to select only the javax.servlet bundle. To do that click on Content tab and select Location in the Group By combo Box to group plugins by folder which have defined (The « Group By » Location can take several times) :

Un-select the whole plugins from the ${eclipse_home} and select ONLY the javax.servlet bundle

InstallTarget Platform (2)

Now you can re-install the Target Platform by clicking on Set As Target Platform. Your workspace is recompiled with no compilation errors :

Pay just attention that the javax.servlet used provides the 2.5 Servlet specification.


This article show you it’s important to define Target Platform with OSGi Equinox in a Servlet Container to use in your workspace the bundles coming from bridge/WebContent/WEB-INF/eclipse/plugins folder (and not coming from the Eclipse IDE).

In the [step4], I will explain how it’s possible to use directly bundles coming from the workspace (no need to create the bundle JAR) and how it’s possible to host resources (HTML, Servlet, Javascript…) in the bridge WEB Application.

Catégories :Equinox ServletBridge
  1. Amy Arthur
    février 13, 2013 à 4:24

    Hi Angelo, You have a great post here! I learned alot!

    I have a problem with the war file with my bundles in Tomcat 7 (it deploys ok, but crashes when I point to the url in runtime), it gave me
    org.osgi.framework.BundleException: The bundle « mysample.osgi_3.6.3″ could not be resolved. Reason: Missing Constraint: Require-Bundle: mysample.admin; bundle-version= »0.0.0 »
    I can use the exact same war file with the same bundles successfully deployed and run fine in Tomcat 6. Someone told me that’s because of Tomcat 7 uses javax.servlet 3.0 whereas Tomcat 6 uses the 2.x version.
    Do you know if there’s any simple work around to fix this instead of rebuilding the bundle with javax.servlet 3.0?

    • février 13, 2013 à 7:48

      Hi Amy,

      Sorry I cannot help you, I have written this article a long time ago and it’s difficult for me to help you about this topic.

      Good luck!

      Regards Angelo

  2. dee
    mars 19, 2013 à 1:23

    Hi Angelo,

    Nice article, got to learn a lot, just wanted to check with you if the following setup is supported –

    App Server – Weblogic 10.3.3
    OSGi Impl – Equinox/Felix
    Spring MVC web application
    Spring DM

    This is the OSGi in a App Server kind of scenario.

    Thanks in advance.

    • mars 19, 2013 à 1:29

      Hi dee,

      I’m sorry I can’t help you, never used Spring MVC and never played with OSGi with Weblogic.

      Good luck!

      Regards Angelo

  1. septembre 6, 2010 à 1:21
  2. septembre 8, 2010 à 1:48

Votre commentaire

Entrez vos coordonnées ci-dessous ou cliquez sur une icône pour vous connecter:


Vous commentez à l’aide de votre compte Déconnexion /  Changer )

Photo Google

Vous commentez à l’aide de votre compte Google. Déconnexion /  Changer )

Image Twitter

Vous commentez à l’aide de votre compte Twitter. Déconnexion /  Changer )

Photo Facebook

Vous commentez à l’aide de votre compte Facebook. Déconnexion /  Changer )

Connexion à %s

%d blogueurs aiment cette page :