2 Replies Latest reply on Aug 6, 2012 1:07 AM by binglim

    Is it possible to get the StatefulKnowledgeSession/processInstance from solely its ID?

    binglim Newbie



      I have some questions on how to obtain the StatefulKnowledgeSession or processInstance that is running concurrently with another program.


      From the documentation, it states that it's possible to make external calls using




      When I run my first .java file, I stored the current ksession.getId() and processInstanceId into a xml file and have a signal node at the converging gateway to wait for external signaling before continuing with the workflow.




      After that, I ran another bpmn workflow that reads the xml file for both the ksession ID and processInstance ID.

      However, I do not know how to use those 2 information to signal the signal node from the first bpmn workflow to continue with the workflow.


      (I was able to print out the String reperesentation of the 2 IDs but whenever I create a new ksession and do   ksession.getWorkItemManager().registerWorkItemHandler("Signaling", new Signaling(ksession.getProcessInstance(Id)));

      I kept getting nullPointerException )

      -Signaling is a service node that does either ProcessInstance.signalEvent("Signal", null);  or session.signalEvent("Signal", null); (Tried both ways but didn't work)


      Any help is greatly appreciated. Thanks in advance!


      Best Regards,


        • 1. Re: Is it possible to get the StatefulKnowledgeSession/processInstance from solely its ID?
          Maciej Swiderski Master

          First question - do you use persistence for your processes? If so and they share same data store (data base) you should be able to signal process instance just using signalEvent method on the session as that should be capable of finding all process instances waiting for that event (defined by type). If you don't use persistence then you must have to get access to actual session instance that holds the process instance as it only lives in that session (memory).


          Would be perfect to get a test case that reproduces that or at least more information about the exception (stack trace, etc).



          • 2. Re: Is it possible to get the StatefulKnowledgeSession/processInstance from solely its ID?
            binglim Newbie

            Hi Maciej,


            Thanks for your response.


            I implemented persistence but I'm thinking that there might be configuration problems that's causing the error I have right now.


            The exceptions I got are:



            java.lang.IllegalStateException: java.lang.reflect.InvocationTargetException

                      at org.drools.persistence.jpa.KnowledgeStoreServiceImpl.buildCommandService(KnowledgeStoreServiceImpl.java:143)

                      at org.drools.persistence.jpa.KnowledgeStoreServiceImpl.newStatefulKnowledgeSession(KnowledgeStoreServiceImpl.java:67)

                      at org.drools.persistence.jpa.JPAKnowledgeService.newStatefulKnowledgeSession(JPAKnowledgeService.java:122)

                      at com.sample.ProcessMain.main(ProcessMain.java:62)

            Caused by: java.lang.reflect.InvocationTargetException

                      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

                      at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)

                      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)

                      at java.lang.reflect.Constructor.newInstance(Unknown Source)

                      at org.drools.persistence.jpa.KnowledgeStoreServiceImpl.buildCommandService(KnowledgeStoreServiceImpl.java:129)

                      ... 3 more

            Caused by: java.lang.NullPointerException

                      at org.drools.persistence.SingleSessionCommandService.<init>(SingleSessionCommandService.java:168)

                      ... 8 more


            Regarding the database, is the databse implemented within JBPM? By using JPAKnowledgeService and EntityManager, does it has a specific database that stores the information I need?

            I have attached the files in a zip folder in the original post, if you need any additional information.


            Thanks a lot for offering your help and I look forward to hearing from you.