12 Replies Latest reply on Feb 26, 2014 8:52 PM by Suraj Bahl

    How to view historical process instances in bpm6.0.1?

    Suraj Bahl Newbie

      Hi,

       

      I want to show all process instances which have been completed. Once all tasks in a process is completed then instance object becomes null so cannot see it's status as completed.

       

      Which jBPM API's i can use to view the historical process instances?

       

      Regards,

      Suraj

        • 1. Re: How to view historical process instances in bpm6.0.1?
          Jay Guidos Novice

          If you are using CDI you can inject an instance of RuntimeDataService which will query the JPA database:

           

           

            @Inject
              private RuntimeDataService rds;
          
              public void reportProcessInstances(List<Integer> states, String processId)
             {
                  for (ProcessInstanceDesc pid : rds.getProcessInstancesByProcessId(allStates, processId, null))
                      ...
              }
          
          

           

          HTH,

          Jay

          • 2. Re: How to view historical process instances in bpm6.0.1?
            Maciej Swiderski Master

            on top of what Jay has already provided you can use directly the AuditLogService to get access to history data.

             

            HTH

            • 3. Re: How to view historical process instances in bpm6.0.1?
              Suraj Bahl Newbie

              Hi,

               

              I tried to fetch the process instance by injecting RuntimeDataService as mentioned by Jay using following method:

               

              ProcessIntanceDesc processInstanceDesc = rds.getProcessInstanceById(processID);

               

              But I am getting following error:

               

              java.lang.IllegalArgumentException: Named query not found: getProcessInstanceById

               

              Do i need to include add some other jar to include the queries executed by RuntimeDataServiceImpl?

               

              regards,

              Suraj


              • 4. Re: How to view historical process instances in bpm6.0.1?
                Jay Guidos Novice

                HI Suraj,

                 

                That particular query is in jbpm-kie-services.  If you want, you can include all these maven dependencies (below).  You may or may not need them all, so if you prefer you can add them one at a time.

                 

                Jay

                 

                        <dependency>

                            <groupId>org.jbpm</groupId>

                            <artifactId>jbpm-flow</artifactId>

                            <scope>compile</scope>

                        </dependency>

                        <dependency>

                            <groupId>org.jbpm</groupId>

                            <artifactId>jbpm-flow-builder</artifactId>

                            <scope>compile</scope>

                        </dependency>

                        <dependency>

                            <groupId>org.jbpm</groupId>

                            <artifactId>jbpm-bpmn2</artifactId>

                            <scope>compile</scope>

                        </dependency>

                        <dependency>

                            <groupId>org.jbpm</groupId>

                            <artifactId>jbpm-persistence-jpa</artifactId>

                            <scope>compile</scope>

                        </dependency>

                        <dependency>

                            <groupId>org.jbpm</groupId>

                            <artifactId>jbpm-human-task-core</artifactId>

                            <scope>compile</scope>

                        </dependency>

                        <dependency>

                            <groupId>org.jbpm</groupId>

                            <artifactId>jbpm-human-task-audit</artifactId>

                            <scope>compile</scope>

                        </dependency>

                        <dependency>

                            <groupId>org.jbpm</groupId>

                            <artifactId>jbpm-runtime-manager</artifactId>

                            <scope>compile</scope>

                        </dependency>

                        <dependency>

                            <groupId>org.jbpm</groupId>

                            <artifactId>jbpm-kie-services</artifactId>

                            <scope>compile</scope>

                        </dependency>

                        <dependency>

                            <groupId>org.jbpm</groupId>

                            <artifactId>jbpm-executor</artifactId>

                            <scope>compile</scope>

                        </dependency>

                        <dependency>

                            <groupId>org.jbpm</groupId>

                            <artifactId>jbpm-kie-services</artifactId>

                            <scope>compile</scope>

                        </dependency>

                        <dependency>

                            <groupId>org.kie</groupId>

                            <artifactId>kie-internal</artifactId>

                            <scope>compile</scope>

                        </dependency>

                        <dependency>

                            <groupId>org.jbpm</groupId>

                            <artifactId>jbpm-workitems</artifactId>

                            <scope>compile</scope>

                        </dependency>

                • 5. Re: How to view historical process instances in bpm6.0.1?
                  Suraj Bahl Newbie

                  Hi Jay,

                   

                  I have already included all the jars which are generated in jBPM runtime folder at the time of installation. The jar "jbpm-kie-services-6.0.1.Final.jar" already exist in my lib folder then any clue why it would not be able to find the query...

                   

                  Thanks,

                  Suraj

                  • 6. Re: How to view historical process instances in bpm6.0.1?
                    Maciej Swiderski Master

                    Suraj,

                     

                    you need to include Servicesorm.xml mapping file in your persistence.xml so the named queries will be available. See here for an example.

                     

                    HTH

                    • 7. Re: How to view historical process instances in bpm6.0.1?
                      Suraj Bahl Newbie

                      Hi Maciej,

                       

                      I'll try that...

                       

                      However, in general i have a question that where can i find all this information? is there any documentation available?

                       

                      I went through jbpm 6 documentation but didn't find anything mentioning about RunTimeDataService or Servicesorm.xml...

                       

                      Regards,

                      Suraj

                      • 9. Re: How to view historical process instances in bpm6.0.1?
                        Suraj Bahl Newbie

                        I have added Servicesorm.xml in my persistence.xml and now i am getting following error on calling:       

                         

                        ProcessInstanceDesc processInstanceLog  = runtimeDataService.getProcessInstanceById(processInstance.getId());

                         

                        Error:

                        12:05:01,705 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) java.lang.IndexOutOfBoundsException: Index: 0, Size: 0

                        12:05:01,705 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at java.util.ArrayList.RangeCheck(Unknown Source)

                        12:05:01,705 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at java.util.ArrayList.get(Unknown Source)

                        12:05:01,705 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at org.jbpm.kie.services.impl.RuntimeDataServiceImpl.getProcessInstanceById(RuntimeDataServiceImpl.java:169)

                        • 10. Re: How to view historical process instances in bpm6.0.1?
                          Maciej Swiderski Master

                          that indicates there is no such process instance, with given id. Might be that logging was not enabled and thus it does not store any data.

                           

                          HTH

                          • 11. Re: How to view historical process instances in bpm6.0.1?
                            Suraj Bahl Newbie

                            Process instance was there. How can i enable the logging?

                            • 12. Re: How to view historical process instances in bpm6.0.1?
                              Suraj Bahl Newbie

                              I am able to see the process from auditservice after removing InjectableRegisterableItemsFactory from my RuntimeEnvironment.