7 Replies Latest reply on Jan 18, 2012 3:08 PM by manarh

    JBoss AS7 cannot find my persistence.xml

    kc7bfi

      EntityManagerFactory emf = Persistence.createEntityManagerFactory("TravelTimeEngine-DS");I am deploying a SAR file that contains a META-INF directory with a persistence.xml file. When the SAR deploys it finds the persistence.xml file and creates the persistemce unit

       

      20:56:00,582 INFO  [org.hibernate.ejb.Ejb3Configuration] (MSC service thread 1-4) HHH000204: Processing PersistenceUnitInfo [

          name: TravelTimeEngine-DS

          ...]

       

      However, when I go to get the persistence unit I get the following error

       

      20:56:08,102 INFO  [org.hibernate.ejb.Ejb3Configuration] (InirxCommunications-2) HHH000318: Could not find any META-INF/persistence.xml file in the classpath

      20:56:08,102 WARN  [com.orci.TravelTimeEngine.hibernate.utils.ThreadTransaction] (InirxCommunications-2) getSessionSafe: javax.persistence.PersistenceException: No Persistence provider for EntityManager named TravelTimeEngine-DS

      20:56:08,102 ERROR [stderr] (InirxCommunications-2) javax.persistence.PersistenceException: No Persistence provider for EntityManager named TravelTimeEngine-DS

       

      20:56:08,102 ERROR [stderr] (InirxCommunications-2)     at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:69)

       

      This is how I am getting the persistence unit:

       

      EntityManagerFactory emf = Persistence.createEntityManagerFactory("TravelTimeEngine-DS");

       

      Any idea what I might be doing wrong? Why it first finds the persistence.xml file but then fails to find it on the classpath?

      Thanks, David

        • 1. Re: JBoss AS7 cannot find my persistence.xml
          ozizka

          DS souns like ur passing datasource name. EMF takes persistence unit name.

          • 2. Re: JBoss AS7 cannot find my persistence.xml
            alesj

            Any idea what I might be doing wrong? Why it first finds the persistence.xml file but then fails to find it on the classpath?

            Are you bundling the JPA impl with your app?

            • 3. Re: JBoss AS7 cannot find my persistence.xml
              kc7bfi

              Yes I am. It seems that having the persistence.xml in the META-INF directory of the SAR is not sufficient. I also have to have it in the JAR that contains the class that I am calling the createEntityManagerFactory() method. Not sure why this is the case. It seems that the SAR is not in the classpath so it cannot find the persistence.xml that is in the SARs META-INF directory.

              • 4. Re: JBoss AS7 cannot find my persistence.xml
                alesj

                So you have strucutre like this?

                 

                my.sar

                * lib

                ** my.jar

                ** <some-jpa-impl>.jar

                * META-INF

                ** persistence.xml

                 

                Bundled JPA impl has issues, as I'm having similar issues when bundling DataNucleus impl as part of my .war.

                I patched AS7 a bit to get around the issue: https://github.com/alesj/jboss-as/commit/278800e24f82c704fec0be14d7d7d2c956880600

                (this is a custom branch, but the hack/workaround might give you some ideas)

                • 5. Re: JBoss AS7 cannot find my persistence.xml
                  kc7bfi

                  Close, but it is

                  my.sar

                  * my.jar

                  * some-jpa-impl.ja

                  * META-INF

                  ** persistence.xml

                   

                  In my SARs the jars are in the root and not under the lib directory. This is how I've done it under as5, should it be different in as7?

                  • 6. Re: JBoss AS7 cannot find my persistence.xml
                    alesj

                    No, it (the structure) used to be different for AS4, hence I thought you still use that .sar notion

                    (as it was originally a simpler way to deploy custom services, but we simplified that with MC).

                     

                    But yeah, my guess would be you're having the same problem as me -- that PPResolverImpl doesn't understand / know your PP.

                    e.g. your PP is found as part of services/ search, but the AS7' PPresolver instance used in javax.persistence.Persistence doesn't know it

                     

                    This definitely needs fixing, the question is just how soon. ;-)

                    • 7. Re: JBoss AS7 cannot find my persistence.xml
                      manarh

                      Ales Justin wrote:

                       

                      So you have strucutre like this?

                       

                      my.sar

                      * lib

                      ** my.jar

                      ** <some-jpa-impl>.jar

                      * META-INF

                      ** persistence.xml

                       

                      Bundled JPA impl has issues, as I'm having similar issues when bundling DataNucleus impl as part of my .war.

                      I patched AS7 a bit to get around the issue: https://github.com/alesj/jboss-as/commit/278800e24f82c704fec0be14d7d7d2c956880600

                      (this is a custom branch, but the hack/workaround might give you some ideas)

                      Ales, is there an JIRA issue for that error - javax.persistence.PersistenceException: No Persistence provider for EntityManager ? I heard from a seam user the same about the same experience with Web application (WAR).