title: EntitityManager not injected properly, always null
body: <p>I have a few JPA entities that are created and persisted in JAX-RS methods. I have a worker thread that processes some data about those entities in JPA over time and while I can pass in the Entity objects, I am unable to persist any changes to them because the EntitityManager in the thread that makes the changes is always null.</p>
  
  <p>The class containing my worker thread is declared as such: </p>
  
  <pre><code>public final class EntityService {
  
  @PersistenceContext(type = PersistenceContextType.EXTENDED)
  EntityManager entityManager;
  </code></pre>
  
  <p>The EntityManager is always null and even if it's passed in from a JAX-RS method as by the time the thread gets a chance to attempt to use the EM, the EM is null as the JAX-RS method has terminated. </p>
  
  <p>How can I get a valid Entity Manager into my Service pojo when injection isn't working? I'm using Hibernate and Wildfly 10</p>