9 Replies Latest reply on Nov 24, 2011 2:06 PM by calca

    jBPM5.1 : History Information and Reporting using API

    sandeepsapra

      I have two queries and pointers/references to them will be a great help to me

       

      1.) History Information : I understand that history can be logged by using

       

      JPAWorkingMemoryDbLogger logger = new JPAWorkingMemoryDbLogger(ksession); 

       

      and the same is working as required.

       

      Ques : How to retreive the information which is logged using API ? Any example. I read in documentation that it is using the Process Event Listener.

      But does it work?

       

      2.) Reporting : Reports for the process can be seen in the jBPM console. But I need to develop mine using APIs

       

      Ques: Any reference for the same?

       

      Regards,

      Sandeep Sapra

        • 1. Re: jBPM5.1 : History Information and Reporting using API
          sandeepsapra

          Can anyone please help me for my query on how to implement Process Event Listener and show history information.?

           

          Regards,

          Sandeep Sapra

          • 2. Re: jBPM5.1 : History Information and Reporting using API
            sandip.bhoi

            We want to log all activities performed in the process workflow as the Process definition mostly contains all Human Tasks.

             

            Please help us.

            • 3. Re: jBPM5.1 : History Information and Reporting using API
              calca
              • 4. Re: jBPM5.1 : History Information and Reporting using API
                sandip.bhoi

                Thank you Demian.

                 

                But after replacing the line

                 

                JPAWorkingMemoryDbLogger jpaLogger = new JPAWorkingMemoryDbLogger(ksession);

                 

                with

                 

                JPAProcessInstanceDbLog  jpaLogger = new JPAProcessInstanceDbLog (ksession.getEnvironment());

                 

                Could not see any significant logging records added in PROCESSINSTANCEINFO and PROCESSINSTANCELOG.

                 

                Could you please let me know the relevant API call to retrive the history details for perticular workflow executed.

                • 5. Re: jBPM5.1 : History Information and Reporting using API
                  calca

                  Hi Sandip,

                   

                  both should be there.

                  JPAWorkingMemoryDbLogger will register a listener and log in the database.

                  JPAProcessInstanceDbLog just queries these tables.

                  • 6. Re: jBPM5.1 : History Information and Reporting using API
                    sandip.bhoi

                    Hi Demian,

                     

                    Sorry for being so dump

                     

                    What could be the wrong with following code. I am getting NPE.

                     

                    public void init() throws ServletException {

                     

                            super.init();

                     

                            try {

                     

                                UserTransaction ut = (UserTransaction) new InitialContext().lookup("java:comp/UserTransaction");

                                ut.begin();

                                StatefulKnowledgeSession ksession = JbpmAPIUtil.getSession();

                     

                                /* Create the knowledge base */

                               

                                JPAWorkingMemoryDbLogger  logger = new JPAWorkingMemoryDbLogger (ksession);

                                JPAProcessInstanceDbLog  processInstaceLogger = new JPAProcessInstanceDbLog (ksession.getEnvironment());

                               

                                CommandBasedWSHumanTaskHandler taskHandler = new CommandBasedWSHumanTaskHandler(ksession);

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

                                taskHandler.connect();

                                ut.commit();

                                logger.dispose();

                                processInstaceLogger.dispose();

                            } catch (Throwable t) {

                                // log.error(t.getMessage(), t.getCause());

                                throw new RuntimeException("error while creating session", t);

                            }

                     

                        }

                     

                    Nov 24, 2011 10:26:14 PM org.apache.catalina.core.ApplicationContext log

                    SEVERE: StandardWrapper.Throwable

                    java.lang.RuntimeException: error while creating session

                        at com.sample.processserver.TaskProcessServlet.init(TaskProcessServlet.java:43)

                        at javax.servlet.GenericServlet.init(GenericServlet.java:160)

                        at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1190)

                        at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1103)

                        at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1010)

                        at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4957)

                        at org.apache.catalina.core.StandardContext$3.call(StandardContext.java:5284)

                        at org.apache.catalina.core.StandardContext$3.call(StandardContext.java:5279)

                        at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)

                        at java.util.concurrent.FutureTask.run(Unknown Source)

                        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)

                        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

                        at java.lang.Thread.run(Unknown Source)

                    Caused by: java.lang.NullPointerException

                        at org.jbpm.process.audit.JPAProcessInstanceDbLog.dispose(JPAProcessInstanceDbLog.java:165)

                        at com.sample.processserver.TaskProcessServlet.init(TaskProcessServlet.java:40)

                        ... 12 more

                    Nov 24, 2011 10:26:14 PM org.apache.catalina.core.StandardContext loadOnStartup

                    SEVERE: Servlet /OrderFactoryWeb threw load() exception

                    java.lang.NullPointerException

                        at org.jbpm.process.audit.JPAProcessInstanceDbLog.dispose(JPAProcessInstanceDbLog.java:165)

                        at com.sample.processserver.TaskProcessServlet.init(TaskProcessServlet.java:40)

                        at javax.servlet.GenericServlet.init(GenericServlet.java:160)

                        at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1190)

                        at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1103)

                        at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1010)

                        at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4957)

                        at org.apache.catalina.core.StandardContext$3.call(StandardContext.java:5284)

                        at org.apache.catalina.core.StandardContext$3.call(StandardContext.java:5279)

                        at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)

                        at java.util.concurrent.FutureTask.run(Unknown Source)

                        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)

                        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

                        at java.lang.Thread.run(Unknown Source)

                    Nov 24, 2011 10:26:14 PM org.apache.solr.servlet.SolrServlet init

                    INFO: SolrServlet.init()

                    • 7. Re: jBPM5.1 : History Information and Reporting using API
                      calca

                      It seems to be a bug in dispose method, which is solved in master:

                      https://github.com/droolsjbpm/jbpm/blob/5.1.0.M1.x/jbpm-bam/src/main/java/org/jbpm/process/audit/JPAProcessInstanceDbLog.java

                      https://github.com/droolsjbpm/jbpm/blob/master/jbpm-bam/src/main/java/org/jbpm/process/audit/JPAProcessInstanceDbLog.java

                       

                      em is null because you never used it.

                       

                      Anyway, to use this Process instance Log,

                      you can just use processInstaceLogger.find<Process/Node/Variable>Instances method to get the information you need.

                      • 8. Re: jBPM5.1 : History Information and Reporting using API
                        sandip.bhoi

                        Thank you Demian.

                         

                        It Works !

                        • 9. Re: jBPM5.1 : History Information and Reporting using API
                          calca

                          Great, plz mark question as resolved