3 Replies Latest reply on Oct 30, 2012 1:03 PM by Maciej Swiderski

    Persistence Issues

    Yogesh Garg Newbie

      Hi all,

       

      I am receiving some issues and they seem to be revovling around persistence. I am using jBPM5.3 and jBOSS AS 7.0.2. I have done a vanilla installation. Please let me know if I am supposed to some customization as well. PFB the persistence.xml which I am using for my project and let me know what is missing or needs to change in it. Also I have included errors I am receiving. I am just plainly  running my project. The project needs a human task so there is one org.jbpm.task. There is one doubt as well, we are not mentioning datasource for task's persistence as well, then how can hibernate know where it should store the objects. Secondly my most of the issues are revolving around org.peristence.jpa. Kindly help me!!!!

       

       

      Persistence.xml

      <?xml version="1.0" encoding="UTF-8"?>
      <persistence version="1.0"
                   xmlns="http://java.sun.com/xml/ns/persistence" 
                   xmlns:orm="http://java.sun.com/xml/ns/persistence/orm" 
                   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 http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_1_0.xsd">
                   
        <persistence-unit name="org.jbpm.persistence.jpa" transaction-type="JTA">
          <provider>org.hibernate.ejb.HibernatePersistence</provider>
          <jta-data-source>jdbc/jbpm-ds</jta-data-source>       
          <mapping-file>META-INF/JBPMorm.xml</mapping-file>
          <mapping-file>META-INF/ProcessInstanceInfo.hbm.xml</mapping-file>
      
          <class>org.jbpm.persistence.processinstance.ProcessInstanceInfo</class>
          <class>org.drools.persistence.info.SessionInfo</class>
          <class>org.drools.persistence.info.WorkItemInfo</class>
      
          <class>org.jbpm.process.audit.ProcessInstanceLog</class>
          <class>org.jbpm.process.audit.NodeInstanceLog</class>
          <class>org.jbpm.process.audit.VariableInstanceLog</class>
      
          <properties>
            <property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/>
            <property name="hibernate.connection.driver_class" value="org.h2.Driver"/>
            <property name="hibernate.connection.url" value="jdbc:h2:tcp://localhost/~/jbpm-db" />
            <property name="hibernate.max_fetch_depth" value="3"/>
            <!-- hbm2ddl.auto MUST BE update! The console will otherwise overwrite the schema with each new thread -->
            <property name="hibernate.hbm2ddl.auto" value="update" />
            <property name="hibernate.connection.username" value="sa"/>
            <property name="hibernate.connection.password" value=""/>
            <property name="hibernate.connection.autocommit" value="false" />
            <property name="hibernate.show_sql" value="true" />
            <property name="javax.persistence.validation.mode" value = "none"/>
      
            <!-- for AS7 -->
            <property name="hibernate.transaction.manager_lookup_class" value="org.jbpm.integration.console.JBPMTransactionManager" />
            <!-- for AS5 -->
            <!-- <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup" /> -->
          </properties>        
        </persistence-unit>
          
           <persistence-unit name="org.jbpm.task">
              <provider>org.hibernate.ejb.HibernatePersistence</provider>
              <mapping-file>META-INF/Taskorm.xml</mapping-file>
              <class>org.jbpm.task.Attachment</class>
              <class>org.jbpm.task.Content</class>
              <class>org.jbpm.task.BooleanExpression</class>
              <class>org.jbpm.task.Comment</class>
              <class>org.jbpm.task.Deadline</class>
              <class>org.jbpm.task.Comment</class>
              <class>org.jbpm.task.Deadline</class>
              <class>org.jbpm.task.Delegation</class>
              <class>org.jbpm.task.Escalation</class>
              <class>org.jbpm.task.Group</class>
              <class>org.jbpm.task.I18NText</class>
              <class>org.jbpm.task.Notification</class>
              <class>org.jbpm.task.EmailNotification</class>
              <class>org.jbpm.task.EmailNotificationHeader</class>
              <class>org.jbpm.task.PeopleAssignments</class>
              <class>org.jbpm.task.Reassignment</class>
              <class>org.jbpm.task.Status</class>
              <class>org.jbpm.task.Task</class>
              <class>org.jbpm.task.TaskData</class>
              <class>org.jbpm.task.SubTasksStrategy</class>
              <class>org.jbpm.task.OnParentAbortAllSubTasksEndStrategy</class>
              <class>org.jbpm.task.OnAllSubTasksEndParentEndStrategy</class>
              <class>org.jbpm.task.User</class>
              <properties>
                  <property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/>
                  <property name="hibernate.connection.driver_class" value="org.h2.jdbcx.JdbcDataSource"/>
                  <property name="hibernate.connection.url" value="jdbc:h2:tcp://localhost/runtime/task" />
                  <property name="hibernate.connection.username" value="sa"/>
                  <property name="hibernate.connection.password" value=""/>
                  <property name="hibernate.connection.autocommit" value="false" />
                  <property name="hibernate.max_fetch_depth" value="3"/>
                  <property name="hibernate.hbm2ddl.auto" value="create" />
                  <property name="hibernate.show_sql" value="true" />
              </properties>
          </persistence-unit>
          
      </persistence>
      
      

       

       

      Error on Console

      ...0
      26/10 16:01:46,245[main] ERROR hibernate.transaction.TransactionManagerLookupFactory.getTransactionManagerLookup  - Could not instantiate TransactionManagerLookup
      
      java.lang.ClassNotFoundException: org.jbpm.integration.console.JBPMTransactionManager
      
      at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
      
      at java.security.AccessController.doPrivileged(Native Method)
      
      at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
      
      at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
      
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
      
      at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
      
      at java.lang.Class.forName0(Native Method)
      
      at java.lang.Class.forName(Class.java:169)
      
      at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:192)
      
      at org.hibernate.transaction.TransactionManagerLookupFactory.getTransactionManagerLookup(TransactionManagerLookupFactory.java:86)
      
      at org.hibernate.cfg.SettingsFactory.createTransactionManagerLookup(SettingsFactory.java:433)
      
      at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:158)
      
      at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2119)
      
      at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2115)
      
      at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1339)
      
      at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
      
      at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:669)
      
      at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:126)
      
      at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:52)
      
      at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:34)
      
      at com.sample.ProcessMain.createKnowledgeSession(ProcessMain.java:154)
      
      at com.sample.ProcessMain.main(ProcessMain.java:51)
      
      Exception in thread "main" javax.persistence.PersistenceException: [PersistenceUnit: org.jbpm.persistence.jpa] Unable to build EntityManagerFactory
      
      at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:677)
      
      at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:126)
      
      at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:52)
      
      at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:34)
      
      at com.sample.ProcessMain.createKnowledgeSession(ProcessMain.java:154)
      
      at com.sample.ProcessMain.main(ProcessMain.java:51)
      
      Caused by: org.hibernate.HibernateException: Could not instantiate TransactionManagerLookup 'org.jbpm.integration.console.JBPMTransactionManager'
      
      at org.hibernate.transaction.TransactionManagerLookupFactory.getTransactionManagerLookup(TransactionManagerLookupFactory.java:93)
      
      at org.hibernate.cfg.SettingsFactory.createTransactionManagerLookup(SettingsFactory.java:433)
      
      at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:158)
      
      at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2119)
      
      at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2115)
      
      at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1339)
      
      at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
      
      at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:669)
      
      ... 5 more
      
      
      

       

      Regards,

      Yogesh Garg

        • 1. Re: Persistence Issues
          joploya Newbie

          Hello Yogesh,

           

          Do you know this link, it can help you maybe.

          https://community.jboss.org/wiki/JBPM-530FinalManualDeploymentGuideForBeginner

           

          Which component of jbpm are you trying to install (jbpm-console-server...)? Do you use jpa1 or jpa2 for persistence?

           

          Regards,

          • 2. Re: Persistence Issues
            Yogesh Garg Newbie

            I have no issues in installing any component. The problem seems to be revovling around persistence.xml. I think jBPM 5.x uses JPA 2.0 and Hibernate 4.x. I went through http://mriet.wordpress.com/2012/04/03/jpa-2-with-drools-and-jbpm/ and made requiste changes. I have made following changes:

             

            1. Commented  <mapping-file>META-INF/ProcessInstanceInfo.hbm.xml</mapping-file>. Now the question is do I need to remove this file from the META-INF folder of project as well.
            2. changed 1.0 to 2.0 and _1_.0 to _2_.0 to at required places.
            3. changed JBPMorm.xml to JBPMorm-JPA2.xml.. I have added this file to the META-INF folder of the project as well, let me know if this file needs to be modified as well as I have seen in this thread https://community.jboss.org/message/739318#739318
            4. Changed the transaction manager as well as mentioned.

             

            Although I am rid of these errors, but new ones have cropped up. Have a look at my persistence.xml and error log

             

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

            <persistence version="2.0"

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

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

                         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_2_0.xsd http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_2_0.xsd">

                        

             

                <persistence-unit name="org.jbpm.persistence.jpa" transaction-type="JTA">

                    <provider>org.hibernate.ejb.HibernatePersistence</provider>

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

                    <mapping-file>META-INF/JBPMorm-JPA2.xml</mapping-file>

                    <!-- This line MUST be commented and NOT active when using JPA 2:

                    <mapping-file>META-INF/ProcessInstanceInfo.hbm.xml</mapping-file>

                    -->

                   

                    <class>org.drools.persistence.info.SessionInfo</class>

                    <class>org.jbpm.persistence.processinstance.ProcessInstanceInfo</class>

                    <class>org.drools.persistence.info.WorkItemInfo</class>

                   

                    <properties>

                        <property name="hibernate.max_fetch_depth" value="3"/>

                        <property name="hibernate.hbm2ddl.auto" value="update" />

                        <property name="hibernate.show_sql" value="false" />

                        <!-- The following line is what's used in Hibernate 4 instead of a TransactionManagerLookup class -->

                        <property name="hibernate.transaction.jta.platform" value="org.hibernate.service.jta.platform.internal.BitronixJtaPlatform" />

                       

                        <property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/>

                    

                        <property name="hibernate.connection.driver_class" value="org.h2.Driver" />

                        <property name="hibernate.connection.url" value="jdbc:h2:mem:mydb" />

                        <property name="hibernate.connection.username" value="sa" />

                        <property name="hibernate.connection.password" value="sasa" />

                    </properties>       

                </persistence-unit>

               

                 <persistence-unit name="org.jbpm.task">

                    <provider>org.hibernate.ejb.HibernatePersistence</provider>

                    <mapping-file>META-INF/Taskorm.xml</mapping-file>

                    <class>org.jbpm.task.Attachment</class>

                    <class>org.jbpm.task.Content</class>

                    <class>org.jbpm.task.BooleanExpression</class>

                    <class>org.jbpm.task.Comment</class>

                    <class>org.jbpm.task.Deadline</class>

                    <class>org.jbpm.task.Comment</class>

                    <class>org.jbpm.task.Deadline</class>

                    <class>org.jbpm.task.Delegation</class>

                    <class>org.jbpm.task.Escalation</class>

                    <class>org.jbpm.task.Group</class>

                    <class>org.jbpm.task.I18NText</class>

                    <class>org.jbpm.task.Notification</class>

                    <class>org.jbpm.task.EmailNotification</class>

                    <class>org.jbpm.task.EmailNotificationHeader</class>

                    <class>org.jbpm.task.PeopleAssignments</class>

                    <class>org.jbpm.task.Reassignment</class>

                    <class>org.jbpm.task.Status</class>

                    <class>org.jbpm.task.Task</class>

                    <class>org.jbpm.task.TaskData</class>

                    <class>org.jbpm.task.SubTasksStrategy</class>

                    <class>org.jbpm.task.OnParentAbortAllSubTasksEndStrategy</class>

                    <class>org.jbpm.task.OnAllSubTasksEndParentEndStrategy</class>

                    <class>org.jbpm.task.User</class>

                    <properties>

                        <property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/>

                        <property name="hibernate.connection.driver_class" value="org.h2.jdbcx.JdbcDataSource"/>

                        <property name="hibernate.connection.url" value="jdbc:h2:tcp://localhost/runtime/task" />

                        <property name="hibernate.connection.username" value="sa"/>

                        <property name="hibernate.connection.password" value=""/>

                        <property name="hibernate.connection.autocommit" value="false" />

                        <property name="hibernate.max_fetch_depth" value="3"/>

                        <property name="hibernate.hbm2ddl.auto" value="create" />

                        <property name="hibernate.show_sql" value="true" />

                    </properties>

                </persistence-unit>

               

            </persistence>

             

             

            Error Log

             

            ..Exception in thread "main" javax.persistence.PersistenceException: [PersistenceUnit: org.jbpm.persistence.jpa] Unable to configure EntityManagerFactory

                at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:265)

                at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:125)

                at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:52)

                at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:34)

                at com.sample.ProcessMain.createKnowledgeSession(ProcessMain.java:154)

                at com.sample.ProcessMain.main(ProcessMain.java:51)

            Caused by: org.hibernate.MappingException: Error while parsing file: META-INF/JBPMorm-JPA2.xml

                at org.hibernate.ejb.Ejb3Configuration.addClassesToSessionFactory(Ejb3Configuration.java:937)

                at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:758)

                at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:191)

                at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:253)

                ... 5 more

            Caused by: org.hibernate.MappingException: invalid mapping

                at org.hibernate.cfg.AnnotationConfiguration.addInputStream(AnnotationConfiguration.java:777)

                at org.hibernate.ejb.Ejb3Configuration.addClassesToSessionFactory(Ejb3Configuration.java:929)

                ... 8 more

            Caused by: org.xml.sax.SAXParseException: cvc-complex-type.3.1: Value '2.0' of attribute 'version' of element 'entity-mappings' is not valid with respect to the corresponding attribute use. Attribute 'version' has a fixed value of '1.0'.

                at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)

                at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:131)

                at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:384)

                at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:318)

                at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(XMLSchemaValidator.java:417)

                at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.reportSchemaError(XMLSchemaValidator.java:3182)

                at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.processOneAttribute(XMLSchemaValidator.java:2802)

                at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.processAttributes(XMLSchemaValidator.java:2714)

                at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:2066)

                at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement(XMLSchemaValidator.java:705)

                at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:400)

                at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl$NSContentDriver.scanRootElementHook(XMLNSDocumentScannerImpl.java:626)

                at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:3104)

                at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:922)

                at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)

                at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140)

                at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)

                at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)

                at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)

                at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)

                at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)

                at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)

                at org.dom4j.io.SAXReader.read(SAXReader.java:465)

                at org.hibernate.cfg.AnnotationConfiguration.addInputStream(AnnotationConfiguration.java:773)

                ... 9 more

            0    29/10 14:22:12,885[main] ERROR hibernate.util.XMLHelper.error  - Error parsing XML: XML InputStream(5) cvc-complex-type.3.1: Value '2.0' of attribute 'version' of element 'entity-mappings' is not valid with respect to the corresponding attribute use. Attribute 'version' has a fixed value of '1.0'.

            0    29/10 14:22:12,885[main] ERROR hibernate.util.XMLHelper.error  - Error parsing XML: XML InputStream(18) cvc-complex-type.2.4.a: Invalid content was found starting with element 'mapping-file'. One of '{"http://java.sun.com/xml/ns/persistence/orm":named-query, "http://java.sun.com/xml/ns/persistence/orm":named-native-query, "http://java.sun.com/xml/ns/persistence/orm":sql-result-set-mapping, "http://java.sun.com/xml/ns/persistence/orm":mapped-superclass, "http://java.sun.com/xml/ns/persistence/orm":entity, "http://java.sun.com/xml/ns/persistence/orm":embeddable}' is expected.

            0    29/10 14:22:12,885[main] ERROR hibernate.util.XMLHelper.error  - Error parsing XML: XML InputStream(24) cvc-complex-type.2.4.a: Invalid content was found starting with element 'id'. One of '{"http://java.sun.com/xml/ns/persistence/orm":transient}' is expected.

            0    29/10 14:22:12,885[main] ERROR hibernate.util.XMLHelper.error  - Error parsing XML: XML InputStream(28) cvc-complex-type.3.2.2: Attribute 'access' is not allowed to appear in element 'basic'.

            0    29/10 14:22:12,885[main] ERROR hibernate.util.XMLHelper.error  - Error parsing XML: XML InputStream(29) cvc-complex-type.3.2.2: Attribute 'access' is not allowed to appear in element 'basic'.

            0    29/10 14:22:12,885[main] ERROR hibernate.util.XMLHelper.error  - Error parsing XML: XML InputStream(32) cvc-complex-type.3.2.2: Attribute 'access' is not allowed to appear in element 'basic'.

            0    29/10 14:22:12,885[main] ERROR hibernate.util.XMLHelper.error  - Error parsing XML: XML InputStream(35) cvc-complex-type.3.2.2: Attribute 'access' is not allowed to appear in element 'basic'.

            0    29/10 14:22:12,885[main] ERROR hibernate.util.XMLHelper.error  - Error parsing XML: XML InputStream(38) cvc-complex-type.3.2.2: Attribute 'access' is not allowed to appear in element 'basic'.

            0    29/10 14:22:12,885[main] ERROR hibernate.util.XMLHelper.error  - Error parsing XML: XML InputStream(39) cvc-complex-type.3.2.2: Attribute 'access' is not allowed to appear in element 'basic'.

            0    29/10 14:22:12,885[main] ERROR hibernate.util.XMLHelper.error  - Error parsing XML: XML InputStream(42) cvc-complex-type.3.2.2: Attribute 'access' is not allowed to appear in element 'version'.

             

            Regards.

            • 3. Re: Persistence Issues
              Maciej Swiderski Master

              the error above indicates you most likely have hibernate 3(JPA1) libraries on the class path. Make sure you have them removed when using JBoss AS7 hibernate 4 provider.

               

              HTH