title: How to use OSGI service inside Vaadin web application running in Jboss AS 7
body: <p>I'm new to OSGI and currently trying to use it to create modular web application. Web application itself is created using Vaadin 6.
  I following this WIKI article at Vaadin web site: <a href="https://vaadin.com/wiki/-/wiki/Main/Creating%20a%20Modular%20Vaadin%20Application%20with%20OSGi" rel="nofollow">Creating Modular Vaadin application with OSGI</a></p>
  
  <p>Steps I've did so far:
  - created OSGI bundle for module service (simple service which tracks other osgi modules a.k.a. plugins) and deployed it to jboss.
  - created vaadin application, just a stub.</p>
  
  <p>OSGI service supposed to be injected to Servlet class, like:</p>
  
  <pre><code>@WebServlet(urlPatterns="/*")
  public static class Servlet extends AbstractApplicationServlet {
  
  @Resource(mappedName="vaadin-moduleService")
  ModuleService moduleService;
  
  @Override
  protected Class&lt;? extends Application&gt; getApplicationClass() {
      return ModuleDemoApp.class;
  }
  
  @Override
  protected Application getNewApplication(HttpServletRequest request) throws ServletException {
      return new ModuleDemoApp(moduleService);
  }
  }
  </code></pre>
  
  <p>Now the question - how this service can be injected here? Currently I'm just getting NULL pointer, so DI doesn't work. From article referred above:</p>
  
  <pre><code>Note, that the servlet has a moduleService field annotated with the 
  @Resource annotation. One of the interesting features of GlassFish 3 
  is that it is possible to inject references to OSGi services into all 
  container managed Java beans, even though they are not actually 
  running in the OSGi container themselves. Thus, in this case, GlassFish 
  will find the module service we define in the previous section and inject it.
  </code></pre>
  
  <p>According to this Glassfish will do all the magic internally and automatically. Anyone aware of how to get it done using JBoss7?</p>
  
  <p>Unfortunately didn't find any good (for newbie) explanation on how anything running inside of OSGI container can be referenced outside of it... Suppose that converting of the web application itself to OSGI bundle is not required to acomplish what I need. Is this true?</p>
  
  <p>Thanks a lot.</p>