5 Replies Latest reply on Jun 5, 2012 5:08 AM by Florent GUERIN

    jBPM persistence configuration

    Florent GUERIN Newbie

      Hi,

       

      I have some problem to configure persistence of the data in my application.

      I would like to use jBPM without jndi data source.

       

      this is my persistence.xml file:

       

      <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
      <persistence version="1.0"
                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"
                xmlns:orm="http://java.sun.com/xml/ns/persistence/orm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xmlns="http://java.sun.com/xml/ns/persistence">
      
      
                <persistence-unit name="org.jbpm.persistence"
                          transaction-type="RESOURCE_LOCAL">
                          <provider>org.hibernate.ejb.HibernatePersistence</provider>
      
      
                          <mapping-file>META-INF/JBPMorm.xml</mapping-file>
                          <mapping-file>META-INF/Taskorm.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>
      
      
                          <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>        
                                      <!-- SQL Logs -->
                                    <property name="hibernate.show_sql" value="true" />
                                    <property name="hibernate.format_sql" value="true"/>
                                    <property name="use_sql_comments" value="true"/>
                                    <!-- JDBC connection -->
                                    <property name="hibernate.connection.driver" value="com.mysql.jdbc.Driver" />
                                    <property name="hibernate.connection.username" value="****" />
                                    <property name="hibernate.connection.password" value="****" />
                                    <property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/****" />
                                    <!-- Automatic creation of the schema -->
                                    <property name="hibernate.hbm2ddl.auto" value="create" />
                                    <!-- Hibernate dialect -->
                                     <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" /> 
                          </properties>
                </persistence-unit>
      

       

      Its seems that no data are stored in the database, maybe because i don't define transaction manager.

      I try to use the hibernate.transaction.manager_lookup_class property but i don't know if it is needed when i don't use special server like JBoss...

       

      I would like to activate history log but i don't know how to do this, i try to activate it with JPAWorkingMemoryDbLogger but it doesn't work and produce exceptions.

       

      If someone can help me on this.

       

      Best regards,

       

      Ce message a été modifié par: Florent GUERIN

        • 1. Re: jBPM persistence configuration
          Florent GUERIN Newbie

          anyone can help me on this ?

          • 2. Re: jBPM persistence configuration
            gardellajp Newbie

            Hi Florent,

             

            jbpm-persistent require JTA.  In reference guide explain how to configure with Bitronix.  Can you share the exception that you have?

             

            Juan

            • 3. Re: jBPM persistence configuration
              Florent GUERIN Newbie

              Thanks gardellajp,

               

              I do some modification this afternoon and modify a little my code to integrate Bitronix.

               

              This is my persistence.xml file:

              <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
              <persistence version="1.0"
                        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"
                        xmlns:orm="http://java.sun.com/xml/ns/persistence/orm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                        xmlns="http://java.sun.com/xml/ns/persistence">
              
              
                        <persistence-unit name="org.jbpm.persistence" transaction-type="RESOURCE_LOCAL">
                                  <provider>org.hibernate.ejb.HibernatePersistence</provider>
              
                                  <jta-data-source>jdbc/jbpm</jta-data-source>
              
              
                                  <mapping-file>META-INF/JBPMorm.xml</mapping-file>
                                  <mapping-file>META-INF/Taskorm.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>
              
              
                                  <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>
                                            <!-- SQL Logs -->
                                            <property name="hibernate.show_sql" value="true" />
                                            <property name="hibernate.format_sql" value="true"/>
                                            <property name="use_sql_comments" value="true"/>
                                            <!-- Transaction manager -->
                                            <property name="transaction.manager_lookup_class" value="org.hibernate.transaction.BTMTransactionManagerLookup" />
                                            <!-- Automatic creation of the schema -->
                                            <property name="hibernate.hbm2ddl.auto" value="create" />
                                            <!-- Hibernate dialect -->
                                             <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" /> 
                                  </properties>
                        </persistence-unit>
              
              
              </persistence>
              

               

              On the code to create the PoolingDataSource:

                                            PoolingDataSource poolingDataSource = new PoolingDataSource();
                                            poolingDataSource.setClassName("com.mysql.jdbc.jdbc2.optional.MysqlXADataSource");
                                            poolingDataSource.setUniqueName("jdbc/jbpm");
                                            poolingDataSource.setMaxPoolSize(3);
                                            poolingDataSource.setAllowLocalTransactions(true);
                                            poolingDataSource.setTestQuery("SELECT 1 FROM DUAL");
                                            poolingDataSource.getDriverProperties().setProperty("user", "****");
                                            poolingDataSource.getDriverProperties().setProperty("password", "****");
                                            poolingDataSource.getDriverProperties().setProperty("URL", "jdbc:mysql://localhost:3306/****");
                                            poolingDataSource.init();
              

               

              The table are now created, no exception exept this :

              ATTENTION: cannot get this JVM unique ID. Make sure it is configured and you only use ASCII characters. Will use IP address instead (unsafe for production usage!).

               

              Now i try to activate the history log like i say in my first post. But i don't know how to do this. i try with this :

               

                                            JPAWorkingMemoryDbLogger logger = new JPAWorkingMemoryDbLogger(JbpmHelper.getKnowledgeSession());
                                            JbpmHelper.getKnowledgeSession().startProcess("com.sample.bpmn.hello");
                                            logger.dispose();
              

               

              But i have this exception:

              java.lang.NullPointerException
                        at org.jbpm.process.audit.JPAWorkingMemoryDbLogger.addProcessLog(JPAWorkingMemoryDbLogger.java:90)
                        at org.jbpm.process.audit.JPAWorkingMemoryDbLogger.logEventCreated(JPAWorkingMemoryDbLogger.java:65)
                        at org.drools.audit.WorkingMemoryLogger.filterLogEvent(WorkingMemoryLogger.java:196)
                        at org.drools.audit.WorkingMemoryLogger.beforeProcessStarted(WorkingMemoryLogger.java:421)
                        at org.drools.event.ProcessEventSupport.fireBeforeProcessStarted(ProcessEventSupport.java:40)
                        at org.jbpm.process.instance.ProcessRuntimeImpl.startProcessInstance(ProcessRuntimeImpl.java:167)
                        at org.jbpm.process.instance.ProcessRuntimeImpl.startProcess(ProcessRuntimeImpl.java:138)
                        at org.jbpm.process.instance.ProcessRuntimeImpl.startProcess(ProcessRuntimeImpl.java:130)
                        at org.drools.common.AbstractWorkingMemory.startProcess(AbstractWorkingMemory.java:1077)
                        at org.drools.impl.StatefulKnowledgeSessionImpl.startProcess(StatefulKnowledgeSessionImpl.java:315)
              

               

              Best regards,

               

              Florent

              • 4. Re: jBPM persistence configuration
                gardellajp Newbie

                Well, jbpm persistent/jbpm human task module have a poor error/loggin handling. Much NPE and IllegalArgumentException, but well is a free and opensource product. Some comments:

                 

                1) I recommend use turn to update the value hibernate.hbm2ddl.auto, if not, each restart, recreate tables and you lost all data.

                 

                Put a breakpont at the source code at  org.jbpm.process.audit.JPAWorkingMemoryDbLogger.addProcessLog(JPAWorkingMemoryDbLogger.java:90) and see what is null. 

                • 5. Re: jBPM persistence configuration
                  Florent GUERIN Newbie

                  Thanks,

                   

                  I do the modification for the persistence.xml file.

                  I solved the problem for the history log. I made a mistake on the persistence.xml file.

                  The right syntax is like this for the transaction manager:

                  <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.BTMTransactionManagerLookup" />