2 Replies Latest reply: Sep 13, 2013 11:28 AM by anemdhana RSS

    Unable to retrieve EntityManagerFactory for unitName primary

    anemdhana

      Hi,

      this is the exception thrown when injecting EntityManager.

      Caused by: java.lang.IllegalStateException: Unable to retrieve EntityManagerFactory for unitName primary at com.sun.enterprise.container.common.impl.EntityManagerWrapper.init(EntityManagerWrapper.java:132)

       

      The following exists in ejb module of my maven project.

      public class Resources {
      
          @Produces
          @PersistenceContext(unitName = "primary")
          private EntityManager em;
      

       

      My persistence unit below in the location ejb/src/main/resources/META-INF

       

      <persistence-unit name="primary">
            <!-- If you are running in a production environment, add a managed 
               data source, this example data source is just for development and testing! -->
            <!-- The datasource is deployed as <EAR>/META-INF/glassfish-resources.xml, you
               can find it in the source at ear/src/main/application/META-INF/glassfish-resources.xml -->
            <jta-data-source>java:app/jdbc/myportalDS</jta-data-source>
      

      Pls help me what could be missing in my code.