title: How do I inject a JMS resource in a JAX-RS REST Web Service?
body: <p>Using GlassFish 3.1.2.1, I have configured a JMS connection factory and a queue, which can be injected in JavaServer Faces managed beans using the @Resource annotation.</p>
  
  <p>However when I try to use these JMS resources in a JAX-RS REST web service in the same project, the connectionFactory injection seems to be missing and there is a NullPointerException when the line is executed:</p>
  
  <pre><code>connection = exampleQueueFactory.createConnection();
  </code></pre>
  
  <p>The injection code is</p>
  
  <pre><code>@Resource(mappedName = "ExampleQueue")
  private Queue exampleQueue;
  @Resource(mappedName = "ExampleQueueFactory")
  private ConnectionFactory exampleQueueFactory;
  </code></pre>
  
  <p>and as I successfully use the same injection in JSF managed beans I guess that the GlassFish server skips the JAX-RS classes when looking for injection points. Is there additional configuration missing?</p>