title: PersistenceContext not injecting EntityManager
body: <p>I am getting a NullPointerException when trying to access the <code>EntityManager</code> via annotation <code>PersistenceContext</code></p>
  
  <pre><code>import javax.ejb.Stateless;
  import javax.persistence.EntityManager;
  import javax.persistence.PersistenceContext;
  import javax.persistence.criteria.CriteriaBuilder;
  import javax.persistence.criteria.CriteriaQuery;
  
  @Stateless
  public class UserService {
  
      @PersistenceContext(unitName = "jcrdb")
      private EntityManager em;
  
      ...
  }
  </code></pre>
  
  <p>My <code>persistence.xml</code>in path <code>src/main/webapp/META-INF</code>:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;persistence version="1.0"
      xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"&gt;
      &lt;persistence-unit name="jcrdb" transaction-type="RESOURCE_LOCAL"&gt;
          &lt;provider&gt;org.hibernate.jpa.HibernatePersistenceProvider&lt;/provider&gt;
          &lt;!-- &lt;jta-data-source&gt;jdbc/jcrdb&lt;/jta-data-source&gt; --&gt;
          &lt;exclude-unlisted-classes&gt;false&lt;/exclude-unlisted-classes&gt;
          &lt;properties&gt;
              &lt;property name="hibernate.show_sql" value="true" /&gt;
              &lt;property name="hibernate.format_sql" value="true" /&gt;
              &lt;!-- this tell Hibernate to update the DDL when it starts, very useful 
                  for development, dangerous in production --&gt;
              &lt;property name="hibernate.hbm2ddl.auto" value="update" /&gt;
              &lt;property name="javax.persistence.logging.level" value="INFO" /&gt;
              &lt;property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver" /&gt;
              &lt;property name="javax.persistence.jdbc.url" value="jdbc:postgresql://127.0.0.1:5432/jcrdb" /&gt;
              &lt;property name="javax.persistence.jdbc.user" value="jcr_admin" /&gt;
              &lt;property name="javax.persistence.jdbc.password" value="q1w2e3r4" /&gt;
              &lt;!-- &lt;property name="tomee.jpa.factory.lazy" value="true" /&gt;--&gt;
          &lt;/properties&gt;
      &lt;/persistence-unit&gt;
  &lt;/persistence&gt;
  </code></pre>
  
  <p>The <code>User</code>-class:</p>
  
  <pre><code>@Entity
  @Table(name = "Users")
  public class User {
  
      @Id
      @GeneratedValue(generator = "increment")
      @GenericGenerator(name = "increment", strategy = "increment")
      private int UserId;
      private String alias;
      private String email;
      @OneToOne(fetch = FetchType.LAZY)
      private Person person;
      @OneToMany
      private List&lt;Role&gt; roles;
  
      public User() {
  
      }
  
      // constructor, getters, setters...
  }
  </code></pre>
  
  <p>There is no problem getting the EntityManager directly like this:</p>
  
  <pre><code>EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory("jcrdb");
  em = entityManagerFactory.createEntityManager();
  </code></pre>
  
  <p>I tried running this in jetty and tomEE.</p>
  
  <p>It seems to me that the ejb-stuff isn't working. What am I missing here (new to all this)?</p>