I have the following error using JPA with Eclipse : EntityManager : NULLpointerException.
The code of the class is :
@ManagedBean(name="inputHStockManager")
@RequestScoped
public class InputHStockManager
{
@PersistenceContext(unitName="inventory")
EntityManager em ;
public void getHStockData(){
System.err.println("\n\n" + em + "\n\n");
List<InputHStock> list = em.createQuery("FROM InputHStock").getResultList();
}
}
If I declare the EntityManagerFactory directly in the class :
EntityManagerFactory emf = Persistence.createEntityManagerFactory("inventory");
Then it is working, so the error is related to the injection but whatever I try I don't succed in solving it.