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

    Log tables not persisted

    Rajan Bansal Newbie

      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:



      <?xml version="1.0"?>

      <!DOCTYPE hibernate-mapping PUBLIC

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





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

              <id name="id">

                  <generator class="native"/>


              <property name="processInstanceId"/>

              <property name="processId"/>

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

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



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

              <id name="id">

                  <generator class="native"/>


              <property name="type"/>

              <property name="nodeInstanceId"/>

              <property name="nodeId"/>

              <property name="processInstanceId"/>

              <property name="processId"/>

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






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

      <!DOCTYPE hibernate-configuration PUBLIC

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







              <!-- Database connection settings -->

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

              <property name="connection.url">jdbc:oracle:thin:@</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"/>






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


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

      <persistence version="1.0"



                                       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">





























            <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" />








      Give your suggestions please...

        • 1. Re: Log tables not persisted
          Maciej Swiderski Master

          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


          • 2. Re: Log tables not persisted
            Mauricio Salatino Master

            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.


            • 3. Re: Log tables not persisted
              Rajan Bansal Newbie



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



              • 4. Re: Log tables not persisted
                Rajan Bansal Newbie

                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("", 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...");





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

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

                                taskClient.connect("", 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...



                Rajan Bansal

                • 5. Re: Log tables not persisted
                  Rajan Vij Newbie

                  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
                    Rajan Bansal Newbie

                    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.



                    • 7. Re: Log tables not persisted
                      Rajan Vij Newbie

                      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
                        Rajan Bansal Newbie

                        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.



                        • 9. Re: Log tables not persisted
                          Rajan Vij Newbie

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