I'm stuck between a rock and a hard place at the moment with this problem. If I define my persistence context as:
@PersistenceContext(unitName = "persistentUnit")
private EntityManager entityManager;
Glassfish refused to start with the error:
SEVERE: Could not resolve a persistence unit corresponding to the persistence-context-ref-name [com.ckd.business.MusicService/entityManager] in the scope of the module called [home]. Please verify your application.
But if I changed the declaration to:
e@PersistenceContext(name = "persistentUnit")
private EntityManager entityManager;
Glassfish is able to deploy my WAR file but when I load the page up I get this:
java.lang.IllegalStateException: Unable to retrieve EntityManagerFactory for unitName null
What the heck?! I have saved the persistence.xml file to WEB-INF\classes\META-INF directory as per the requirement and saw that Glassfish has loaded JPA properly. But it doesn't matter what I do, Glassfish always fail. I'm using Glassfish 3.1 OpenSource Edition.
Does anyone know of a solution or a workaround for this? Thanks.