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.
The class containing my worker thread is declared as such:
public final class EntityService {
@PersistenceContext(type = PersistenceContextType.EXTENDED)
EntityManager entityManager;
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.
How can I get a valid Entity Manager into my Service pojo when injection isn't working? I'm using Hibernate and Wildfly 10