4 Replies Latest reply on Oct 15, 2013 1:05 AM by Sachin Dhingra

    javax.persistence.PersistenceException: [PersistenceUnit: COMTransactions] Unable to build EntityManagerFactory

    Sachin Dhingra Newbie

      Hi,

       

      I have started deployment of my ear file on the JBOSS 7.1.1 final which contains jar and war files. I have EntityBean in my jar file connectiong to database using JPA i.e., persistence.xml file but getting below error:

       

      server.log:

      18:03:20,871 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-6) MSC00001: Failed to start service jboss.persistenceunit."xxxHubEJB.jar#COMTransactions": org.jboss.msc.service.StartException in service jboss.persistenceunit."xxxHubEJB.jar#COMTransactions": Failed to start service

          at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1767) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

          at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_26]

          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_26]

          at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_26]

      Caused by: javax.persistence.PersistenceException: [PersistenceUnit: COMTransactions] Unable to build EntityManagerFactory

          at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:914)

          at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:889)

          at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:73)

          at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:162)

          at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.start(PersistenceUnitServiceImpl.java:85)

          at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

          at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

          ... 3 more

      Caused by: org.hibernate.AnnotationException: Cannot find the expected secondary table: no UPLD_PRGS_RPT available for com.xxx.xxxhubserver.com.entity.TransactionEntityBean

          at org.hibernate.cfg.Ejb3Column.getJoin(Ejb3Column.java:363)

          at org.hibernate.cfg.Ejb3Column.getTable(Ejb3Column.java:342)

          at org.hibernate.cfg.annotations.SimpleValueBinder.make(SimpleValueBinder.java:306)

          at org.hibernate.cfg.annotations.PropertyBinder.makePropertyAndValue(PropertyBinder.java:189)

          at org.hibernate.cfg.annotations.PropertyBinder.makePropertyValueAndBind(PropertyBinder.java:201)

          at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:2011)

          at org.hibernate.cfg.AnnotationBinder.processIdPropertiesIfNotAlready(AnnotationBinder.java:765)

          at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:684)

          at org.hibernate.cfg.Configuration$MetadataSourceQueue.processAnnotatedClassesQueue(Configuration.java:3406)

          at org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3360)

          at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1334)

          at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1724)

          at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:84)

          at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:904)

          ... 9 more

       

      persistence.xml:

      <?xml version="1.0" encoding="UTF-8"?>

      <persistence xmlns="http://java.sun.com/xml/ns/persistence"

      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

      xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"

      version="1.0">

          <persistence-unit name="COMTransactions">

          <description>COM Transactions status checker</description>

              <jta-data-source>jdbc/COMDB</jta-data-source>

              <jar-file>xxxHubEJB.jar</jar-file>

              <class>com.xxx.xxxhubserver.com.entity.TransactionEntityBean</class>

              <class>com.xxx.xxxhubserver.com.sessionbean.UploadDataStatusBean</class>

          </persistence-unit>

      </persistence>

       

      Attaching standalone.xml file.

       

      Please reply and thanks for the help in advance.

        • 1. Re: javax.persistence.PersistenceException: [PersistenceUnit: COMTransactions] Unable to build EntityManagerFactory
          Tomaz Cerar Master

          bundled hibernate 3?

           

          why don't you use server provided hibernate 4?

          • 2. Re: javax.persistence.PersistenceException: [PersistenceUnit: COMTransactions] Unable to build EntityManagerFactory
            Sachin Dhingra Newbie

            Hi Toamz,

             

            I have used the EAP 6.1.0 GA version now as and I am still getting same error.

             

            Could you please tell me how would i know that whether it is integrated with which hibernate version?

             

            I have checked my standalone.xml file and below are the contents which tells to me that the server has hibernate 4.0.

             

            <cache-container name="hibernate" default-cache="local-query" module="org.jboss.as.jpa.hibernate:4">

                            <local-cache name="entity">

                                <transaction mode="NON_XA"/>

                                <eviction strategy="LRU" max-entries="10000"/>

                                <expiration max-idle="100000"/>

                            </local-cache>

                            <local-cache name="local-query">

                                <transaction mode="NONE"/>

                                <eviction strategy="LRU" max-entries="10000"/>

                                <expiration max-idle="100000"/>

                            </local-cache>

                            <local-cache name="timestamps">

                                <transaction mode="NONE"/>

                                <eviction strategy="NONE"/>

                            </local-cache>

                        </cache-container>

            • 3. Re: javax.persistence.PersistenceException: [PersistenceUnit: COMTransactions] Unable to build EntityManagerFactory
              Scott Marlow Master

              I honestly don't know if the databasemetadata calls are shown when TRACE logging is enabled for the datasource but that is probably the first thing that I would check (after making sure the table is in the backend database as well).

               

              See "To see what is going on at the JDBC level, enable jboss.jdbc.spy DEBUG and add spy="true" to the datasource" as described in the troubleshooting section here.  Also wouldn't hurt to enable TRACE logging for org.hibernate as well.  I also would try using WildFly 8 (latest build) to make sure your not chasing an already fixed issue.

              1 of 1 people found this helpful
              • 4. Re: javax.persistence.PersistenceException: [PersistenceUnit: COMTransactions] Unable to build EntityManagerFactory
                Sachin Dhingra Newbie

                I tried spy option but it is not logging those messages to log file which seems to be it is not reaching till the point where it tries accessing the DB.

                 

                But when I read the error message correct, then Hibernate tries to access UPLD_PRGS_RPT as an secondary table. But UPLD_PRGS_RPT is my primary and not secondary table.

                 

                For that I found that Hibernate expect the table name in the @Column attribute ONLY for the attributes mapped to the secondary table not for primary table. After making those code changes it worked fine.

                 

                Thanks you Tomaz and Scott.