title: Simple Web Application Bundle(WAB) in tomcat osgi implementation
body: <p>I am having trouble accessing a simple WAB deployed in tomcat using servletbridge osgi implementation.</p>
  
  <p>I was able to programmatically register jsp/servlets/html using HttpService using pure osgi bundles and can access this bundle. The next thing i tried was creating a separate WAB containing one html and one servlet resource, but running into some issues accessing the bundle. I tried both jarred and unjarred bundle. What I am assuming right now is that for a WAB I am not required to register my resources either programmatically or in a declarative way ???</p>
  
  <p>Below is the WAB bundle which I have created. It does not contain any Http Service Tracker, just an activator to show an activation and deactivation message on console.</p>
  
  <pre><code>sample.http1
  
     helloworld.html
  
     |META-INF 
         MANIFEST.MF
  
     |WEB-INF
        web.xml
        |classes
             |sample
                   |http
                        Activator.class
                        HelloWorldServlet.class
  </code></pre>
  
  <p>Below is the MANIFEST.MF file</p>
  
  <pre><code>Manifest-Version: 1.0
  Bundle-ManifestVersion: 2
  Bundle-Name: sample.http1
  Bundle-SymbolicName: sample.http1
  Bundle-Version: 1.0.0
  Bundle-Activator: sample.http.Activator
  Import-Package: javax.servlet,javax.servlet.http,org.osgi.framework, org.osgi.service.http, org.osgi.util.tracker
  Bundle-ClassPath: WEB-INF/classes
  Web-ContextPath: /samplehttp
  </code></pre>
  
  <p>Below is the code for Activator class</p>
  
  <pre><code>package sample.http;
  import org.osgi.framework.BundleActivator;
  import org.osgi.framework.BundleContext;
  public class Activator implements BundleActivator {
  
      public void start(BundleContext context) throws Exception {
      System.out.println("Starting Hello World");
  }
          public void stop(BundleContext context) throws Exception {
            System.out.println("Stopping Hello World");
  }       
  }
  </code></pre>
  
  <p>Below is the content of web.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app&gt;
  &lt;servlet&gt;
  &lt;servlet-name&gt;helloworld&lt;/servlet-name&gt;
  &lt;servlet-class&gt;sample.http.HelloWorldServlet&lt;/servlet-class&gt;
  &lt;/servlet&gt;
  &lt;servlet-mapping&gt;
  &lt;servlet-name&gt;helloworld&lt;/servlet-name&gt;
  &lt;url-pattern&gt;/helloworld&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>I then activated this bundle. And tried accessing the WAB resources as below, but i am getting a 404 page resource not found error. </p>
  
  <p><code>http://localhost/bridge/samplehttp/helloworld.html</code>   --for the static html</p>
  
  <p><code>http://localhost/samplehttp/helloworld.html</code></p>
  
  <p><code>http://localhost/bridge/samplehttp/helloworld</code>   --for the HelloWorldServlet</p>
  
  <p><code>http://localhost/samplehttp/helloworld</code></p>
  
  <p>Tomcat is hosted on port 80. and i can access my other osgi bundles which are registered programmatically using HttpService. The Below osgi bundle works perfectly.</p>
  
  <p>e.g  <code>http://localhost/bridge/jsp-examples/helloworld.jsp</code></p>
  
  <p>Please advice. I have referred the osgi specification document and an another blog at 
  <a href="http://www.javabeat.net/2011/11/writing-an-osgi-web-application/" rel="nofollow">http://www.javabeat.net/2011/11/writing-an-osgi-web-application/</a></p>