9 Replies Latest reply on Jun 28, 2012 12:16 PM by rajvij

    Log tables not persisted

    rajan01

      Actually I successfully persisted the PROCESSINSTANCEINFO, WORKITEMINFO, SESSIONINFO, TASK in Oracle 10g by running jBPM5.1 in JBosss

       

      My issue is the tables:- PROCESSINSTANCELOG, NODEINSTANCELOG, VARIABLEINSTANCELOG are not persisted or we can say no data is showing in these tables:

       

      Below are my "jbpm-bam-5.1.0.Final.jar" files:

       

      AuditLoghbm.xml


      <?xml version="1.0"?>

      <!DOCTYPE hibernate-mapping PUBLIC

              "-//Hibernate/Hibernate Mapping DTD 3.0//EN"

              "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

       

      <hibernate-mapping>

       

          <class name="org.jbpm.process.audit.ProcessInstanceLog" >

              <id name="id">

                  <generator class="native"/>

              </id>

              <property name="processInstanceId"/>

              <property name="processId"/>

              <property name="start" type="timestamp" column="START_DATE"/>

              <property name="end" type="timestamp" column="END_DATE"/>

          </class>

       

          <class name="org.jbpm.process.audit.NodeInstanceLog" >

              <id name="id">

                  <generator class="native"/>

              </id>

              <property name="type"/>

              <property name="nodeInstanceId"/>

              <property name="nodeId"/>

              <property name="processInstanceId"/>

              <property name="processId"/>

              <property name="date" type="timestamp" column="LOG_DATE"/>

          </class>

       

      </hibernate-mapping>

       

      hibernate.cfg.xml


      <?xml version='1.0' encoding='utf-8'?>

      <!DOCTYPE hibernate-configuration PUBLIC

              "-//Hibernate/Hibernate Configuration DTD 3.0//EN"

              "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

       

      <hibernate-configuration>

       

          <session-factory>

       

              <!-- Database connection settings -->

              <property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>

              <property name="connection.url">jdbc:oracle:thin:@172.25.8.251:1521:lupin</property>

              <!--property name="connection.url">jdbc:h2:file:/NotBackedUp/data/mydb</property-->

              <property name="connection.username">jbpm5</property>

              <property name="connection.password">lupin</property>

       

              <!-- JDBC connection pool (use the built-in) -->

              <property name="connection.pool_size">5</property>

       

              <!-- SQL dialect -->

              <property name="dialect">org.hibernate.dialect.Oracle10gDialect</property>

       

              <!-- Enable Hibernate's automatic session context management -->

              <property name="current_session_context_class">thread</property>

       

              <!-- Disable the second-level cache  -->

              <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>

       

              <!-- Echo all executed SQL to stdout -->

              <property name="show_sql">true</property>

       

              <!-- Drop and re-create the database schema on startup -->

              <property name="hbm2ddl.auto">validate</property>

       

              <mapping resource="AuditLog.hbm.xml"/>

       

          </session-factory>

       

      </hibernate-configuration>

       

      and my Persistence.xml present in jbpm-persistence-jpa.jar is

       

      <?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.jpa" transaction-type="JTA">

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

      <jta-data-source>java:/testDS1</jta-data-source>

       

       

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

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

              <class>org.jbpm.persistence.processinstance.ProcessInstanceEventInfo</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.Task</class>

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

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

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

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

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

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

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

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

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

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

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

       

         

         <properties>

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

            <property name="hibernate.connection.driver_class" value="oracle.jdbc.driver.OracleDriver"/>

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

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

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

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

          </properties>

       

        </persistence-unit>

       

       

      </persistence>

       

      Give your suggestions please...

        • 1. Re: Log tables not persisted
          swiderski.maciej

          Have you added event listener that will be responsible for persisting the history log on the session?

           

          Here comes the extract from documentation

          StatefulKnowledgeSession ksession = ...;
          
          JPAWorkingMemoryDbLogger logger = new JPAWorkingMemoryDbLogger(ksession);
          
          // invoke methods one your session here
          
          logger.dispose();
          

          HTH

          • 2. Re: Log tables not persisted
            salaboy21

            The logger is important.. because if you don't add it you will not see any error when something goes wrong in the database side.

            Cheers

            • 3. Re: Log tables not persisted
              rajan01

              Thanks..

               

              This is the one which I left in my code..

               

              Regards.

              • 4. Re: Log tables not persisted
                rajan01

                Its okay...

                 

                The data is persisted in the Log tables in the Oracle database.

                 

                But, when I runs the following code without loggers:-

                 

                JPAWorkingMemoryDbLogger logger = new JPAWorkingMemoryDbLogger(ksession);

                            WSHumanTaskHandler objWSHuman= new WSHumanTaskHandler();

                            objWSHuman.setConnection("127.0.0.1", 9123);

                            ksession.getWorkItemManager().registerWorkItemHandler("Human Task",objWSHuman);

                            // start a new process instance

                            Map<String, Object> params = new HashMap<String, Object>();

                            params.put("initiator", objTargetBean.getEmpName());

                            params.put("reason", "Yearly performance evaluation");

                            ProcessInstance prs= ksession.startProcess("targetSettingFlow", params);

                            System.out.println("okay Process Start is done...");

                            Thread.sleep(1000);

                            logger.dispose();

                 

                 

                            TaskClient taskClient = new TaskClient(new MinaTaskClientConnector("MinaConnector",

                                    new MinaTaskClientHandler(SystemEventListenerFactory.getSystemEventListener())));

                                taskClient.connect("127.0.0.1", 9123);

                                BlockingTaskSummaryResponseHandler taskSummaryHandler = new BlockingTaskSummaryResponseHandler();

                                taskClient.getTasksAssignedAsPotentialOwner(objTargetBean.getEmpName(), "en-UK", taskSummaryHandler);

                                TaskSummary task1 = taskSummaryHandler.getResults().get(0);

                 

                                BlockingTaskOperationResponseHandler taskOperationHandler = new BlockingTaskOperationResponseHandler();

                                 taskOperationHandler = new BlockingTaskOperationResponseHandler();

                                taskClient.start(task1.getId(), objTargetBean.getEmpName(), taskOperationHandler);

                                taskOperationHandler = new BlockingTaskOperationResponseHandler();

                                taskClient.complete(task1.getId(), objTargetBean.getEmpName(), null,  taskOperationHandler);

                 

                then after completing the first human task, it shows the next human task as "Reserved", as a usual behavior or in other words after completing first human task it move to the next one..

                 

                but when I added following two lines:-

                JPAWorkingMemoryDbLogger logger = new JPAWorkingMemoryDbLogger(ksession);

                and   logger.dispose();

                 

                after that, when I complete my first human task, then it not shows the "next one" the un-usual behavior or in other words it just completed the "reserved" one and forgot to move to next human task...

                 

                Is the reason behind is the Log tables not properly persisted or I have to place the logger.dispose(); to somewhere else.

                 

                Note: In the above code, I start the process and complete the first "human task node" in one hit...

                 

                Regards.

                Rajan Bansal

                • 5. Re: Log tables not persisted
                  rajvij

                  Hi Rajan,

                   

                  Something like that is alos happening with me as well. I have created process and they are perfectly working fine, but I really don't c any of them in my DB. There is only one entity that I have created is available with data in db.

                   

                  Properties in persistence.xml

                   

                   

                   

                   

                   

                   

                  <

                   

                  property name="javax.persistence.jdbc.driver" value="org.h2.Driver"

                  />

                   

                  <property name="javax.persistence.jdbc.url" value="jdbc:h2:tcp://localhost/~/test;DB_CLOSE_DELAY=-1;MVCC=TRUE"

                  />

                   

                  <property name="javax.persistence.jdbc.user" value="sa"

                  />

                   

                  <property name="javax.persistence.jdbc.password" value=""

                  />

                   

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

                  />

                   

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

                  />

                   

                  and I don't see test.h2.db being created as well.

                  • 6. Re: Log tables not persisted
                    rajan01

                    For the data-base persistence, along with persistence.xml, make sure you provide the "hibernate-mapping i.e. hbm" and "hibrenate-configuration i.e. cfg" files with proper credentials.

                     

                    And I tell me one thing how you make sure that your process is successfully created.

                     

                    Regards

                    • 7. Re: Log tables not persisted
                      rajvij

                      I have written Entity classes for persisting my buisness data and I believe same is done with jbpm5 classes. So we don't need hbm.xml files.

                       

                      I am creating a tasks for a user on my servlet hit and fetching them on another hit with different params being passed. As far as application is running I can see the tasks list returning from Mina task client ; but nothing in database.(So i am sure tasks are getting created.)

                      • 8. Re: Log tables not persisted
                        rajan01

                        The mina task client is running and persistence data in the primary memory. As soon as the process ends, the data in the memory lost.

                        Mina task client is just the demo to show that how the things work. Its not for the permanent databse storage.

                         

                        So you should not dependent on the mina task client for running your application.

                         

                        Hope this helps.

                         

                        Regards

                        • 9. Re: Log tables not persisted
                          rajvij

                          I was supposed to use CommandWs*Handler for human task instead of WShumantaskhandler.