title: Apache Felix Servlet Bridge setup
body: <p>I'm trying to make my servlet extendable with OSGI bundles: newly added bundles must be a servlets as well. There is a Servlet Bridge feature provided by Felix <a href="http://felix.apache.org/documentation/subprojects/apache-felix-http-service.html" rel="nofollow">http://felix.apache.org/documentation/subprojects/apache-felix-http-service.html</a>, looks very nice for me but I got some problems during its setup. 
  As Felix web page says, in order to to setup servlet bridge we need to do: </p>
  
  <blockquote>
    <ol>
    <li>Deploy org.apache.felix.http.proxy jar file inside the web application (WEB-INF/lib); <strong>[DONE]</strong> </li>
    <li>in a startup listener (like ServletContextListener) set the BundleContext as a servlet context attribute <strong>[DONE]</strong> </li>
    <li>define org.apache.felix.http.proxy.ProxyServlet inside your web.xml and register it to serve on all requests <strong>[DONE]</strong> </li>
    <li>define org.apache.felix.http.proxy.ProxyListener as a  in your web.xml to allow HTTP session related events to be forwarded <strong>[DONE]</strong> </li>
    <li>be sure to add javax.servlet;javax.servlet.http;version=2.6 to OSGi system packages <strong>[not obligatory]</strong> </li>
    <li>deploy org.apache.felix.http.bridge (or org.apache.felix.http.bundle) inside the OSGi framework <strong>[????]</strong> </li>
    </ol>
  </blockquote>
  
  <p>Step No 6 seems to be not enough to make servlet bridge workning in my case. 
  I made all steps 1-5 for my bundle servlet. My main servlet has OSGI embedded mechanism, so I deploy my bundles from the java code. 
  This is a piece of code of OSGI launcher:</p>
  
  <pre><code>Map m = new HashMap();
  m.putAll(System.getProperties());
  m.put(Constants.FRAMEWORK_STORAGE_CLEAN, "onFirstInit");
  m.put(Constants.FRAMEWORK_SYSTEMPACKAGES, "org.osgi.service.http");
  fwk = getFrameworkFactory().newFramework(m);
  fwk.start();
  // Install bundle JAR files and remember the bundle objects.
  BundleContext ctxt = fwk.getBundleContext();
  for (int i = 0; i &lt; jars.size(); i++) { 
      Bundle b = ctxt.installBundle(((File) jars.get(i)).toURI().toString());
      bundleList.add(b);
  }
  // Start all installed non-fragment bundles.
  for (int i = 0; i &lt; bundleList.size(); i++) {
      if (!isFragment((Bundle) bundleList.get(i))) {      
          ((Bundle) bundleList.get(i)).start();
      }
  }
  </code></pre>
  
  <p>From the main servlet code I install required <code>org.apache.felix.http.bridge</code> bundle, some dependencies for my servlet bundle (slf4j, javax.servlet...) and my servlet bundle that I've made following steps 1-5. 
  Deployment result: no HttpService available for Servlet Bundle - it means that I can't use it in my application cause no way to register any Servlet instances in my servlet bundle. </p>
  
  <p>Looking at MANIFEST.MF of <code>org.apache.felix.http.bridge</code> I didn't find any mention like <code>Export-Service: org.osgi.service.http.HttpService</code><br>
  How do I need to use this bundle? How do I need to setup servlet bridge?</p>