@PersistenceUnit annotation won't create an EntityManageFactory emf=null
I'm try to use the Sun Java PetStore Demo. In the CatalogFacade class there is the following annotation: @PersistenceUnit(unitName="myPetStorePU") private EntityManagerFactory emf; In all the methods of the CatalogFacade Sun has: EntityManager em = emf.createEntityManager(); But I am getting a null pointer exception for emf when trying to createEntityManager. But... if I add the following line above that line as such EntityManagerFactory emf = javax.persistence.Persistence.createEntityManagerFactory("myPetStorePU"); EntityManager em = emf.createEntityManager(); then emf gets successfully