Is this the correct way to identify and restart a crashed process instance ?
ksession = JPAKnowledgeService.loadStatefulKnowledgeSession(sessionId, kbase, null, env);
if (ksession != null) {
Collection instances = ksession.getProcessInstances();
if (instances != null && instances.size() > 0) {
for (ProcessInstance processInstance : instances) {
System.out.printf("\n*** Restarting old Business process [%s]\n", processInstance.getProcessId());
// Start the BPM process
ksession.startProcessInstance(processInstance.getId());
// Trigger the signal
ksession.signalEvent("Trigger", null);
// Did the process instance complete successfully ?
if (processInstance.getState() == ProcessInstance.STATE_COMPLETED) {
System.out.printf("\nBusiness process [%s] successfully completed after restart\n", processInstance.getProcessId());
}
}
}
}
else {
System.out.println("***** WARNING: No session found for session-id " + sessionId);
}
This is not working and I get the following exception:
Hibernate: select sessioninf0_.id as id1_0_, sessioninf0_.lastModificationDate as lastModi2_1_0_, sessioninf0_.rulesByteArray as rulesByt3_1_0_, sessioninf0_.startDate as startDate1_0_, sessioninf0_.OPTLOCK as OPTLOCK1_0_ from SessionInfo s
essioninf0_ where sessioninf0_.id=?
0 11/06 20:43:55,210[main] ERROR drools.persistence.SingleSessionCommandService.rollbackTransaction - Could not commit session
java.lang.NullPointerException
at org.jbpm.persistence.processinstance.JPAProcessInstanceManager.getProcessInstances(JPAProcessInstanceManager.java:97)
at org.jbpm.process.instance.ProcessRuntimeImpl.getProcessInstances(ProcessRuntimeImpl.java:200)
at org.drools.common.AbstractWorkingMemory.getProcessInstances(AbstractWorkingMemory.java:1093)
at org.drools.impl.StatefulKnowledgeSessionImpl.getProcessInstances(StatefulKnowledgeSessionImpl.java:292)
at org.drools.command.runtime.process.GetProcessInstancesCommand.execute(GetProcessInstancesCommand.java:35)
at org.drools.command.runtime.process.GetProcessInstancesCommand.execute(GetProcessInstancesCommand.java:28)
at org.drools.command.impl.DefaultCommandService.execute(DefaultCommandService.java:36)
at org.drools.persistence.SingleSessionCommandService.execute(SingleSessionCommandService.java:345)
at org.drools.command.impl.CommandBasedStatefulKnowledgeSession.getProcessInstances(CommandBasedStatefulKnowledgeSession.java:139)
Any ideas ?