title: Inject an EJB into JAX-RS (RESTful service)
body: <p>I'm trying to inject a <em>Stateless EJB</em> into my JAX-RS webservice via annotations. Unfortunately  the EJB is just <code>null</code> and I get a <code>NullPointerException</code> when I try to use it.</p>
  
  <pre><code>@Path("book")
  public class BookResource {
  
      @EJB
      private BookEJB bookEJB;
  
      public BookResource() {
      }
  
      @GET
      @Produces("application/xml")
      @Path("/{bookId}")
      public Book getBookById(@PathParam("bookId") Integer id)
      {
          return bookEJB.findById(id);
      }
  }
  </code></pre>
  
  <p>What am I doing wrong?</p>
  
  <p>Here is some information about my machine:</p>
  
  <ul>
  <li>Glassfish 3.1 </li>
  <li>Netbeans 6.9 RC 2</li>
  <li>Java EE 6</li>
  </ul>
  
  <p>Can you guys show some working example? </p>