Description of problem: Call to 'getProcessInstancees()' in the following code snippet will not return the expected process instance. KieSession ksession = createKnowledgeSession("BPMN2-UserTask.bpmn2"); ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new DoNothingWorkItemHandler()); ProcessInstance pi = ksession.startProcess("UserTask"); System.out.println(ksession.getProcessInstance(pi.getId())); // prints out the instance correctly System.out.println(ksession.getProcessInstances()); // prints an empty list Environment: jBPM with JPA on PostgreSQL 9.1.
This is actually expected behaviour. The getProcessInstances() operation returns the process instances that are currently active in this ksession. When not using persistence, this will be equivalent to all process instances for that ksession (as they all are in memory). However, when using persistence, process instances are only in the ksession during execution of that process instance. As soon as an operation is completed, the process instances are persisted in the database. Changing the implementation of this operation (for example to load all active process instances from database and return those) wouldn't be very useful, as in any real-life system, the number of process instances could be very large. If the user want to know information about which process instances are active etc., the history log aka audit log is the place to search for these. See also JavaDocs: http://docs.jboss.org/jbpm/v5.4/javadocs/org/drools/runtime/process/ProcessRuntime.html#getProcessInstances%28%29 I would therefore recommend closing this as not a bug. Please let me know if you disagree, so we can discuss alternatives.
If the active statement in the documentation does not refer to ProcessInstance.STATE_ACTIVE then please close the issue.