Hi, We're running an application that uses Drools + JBPM 5 + Drools integration our set-up can be seen as:
Some rule fires and creates a JBPM process ( a fact gets inserted into drools using "kcontext.getKnowledgeRuntime().startProcess("testProcess")" ). We have a problem with the persistence of this processes. Persistence is implemented with JPA and JTA. Our application runs with fireUntilHalt() and when a process is launched from the consequence of any of the rules the persistence of the process fails. If the application runs with fireAllRules(), the persistence works like a charm. The error shown is as follow: Exception in thread "Thread-5" Exception executing consequence for rule "Run Process" in com.sample: java.lang.NullPointerException at org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39) at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1101) at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1029) at org.drools.common.DefaultAgenda.fireUntilHalt(DefaultAgenda.java:1229) at org.drools.common.AbstractWorkingMemory.fireUntilHalt(AbstractWorkingMemory.java:754) at org.drools.common.AbstractWorkingMemory.fireUntilHalt(AbstractWorkingMemory.java:730) at org.drools.command.runtime.rule.FireUntilHaltCommand$1.run(FireUntilHaltCommand.java:50) at java.lang.Thread.run(Thread.java:662) Caused by: java.lang.NullPointerException at org.jbpm.persistence.processinstance.JPAProcessInstanceManager.addProcessInstance(JPAProcessInstanceManager.java:44) at org.jbpm.process.instance.AbstractProcessInstanceFactory.createProcessInstance(AbstractProcessInstanceFactory.java:36) at org.jbpm.process.instance.ProcessRuntimeImpl.startProcess(ProcessRuntimeImpl.java:182) at org.jbpm.process.instance.ProcessRuntimeImpl.createProcessInstance(ProcessRuntimeImpl.java:154) at org.jbpm.process.instance.ProcessRuntimeImpl.startProcess(ProcessRuntimeImpl.java:135) at org.jbpm.process.instance.ProcessRuntimeImpl.startProcess(ProcessRuntimeImpl.java:130) at org.drools.common.AbstractWorkingMemory.startProcess(AbstractWorkingMemory.java:1074) at org.drools.impl.StatefulKnowledgeSessionImpl.startProcess(StatefulKnowledgeSessionImpl.java:301) at com.sample.Rule_Run_Process.defaultConsequence(Rule_Run_Process.java:9) at com.sample.Rule_Run_ProcessDefaultConsequenceInvoker.evaluate(Unknown Source) at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1091) ... 6 more The problem is in this function: public void addProcessInstance(ProcessInstance processInstance) { ProcessInstanceInfo processInstanceInfo = new ProcessInstanceInfo( processInstance, this.kruntime.getEnvironment() ); ProcessPersistenceContext context = ((ProcessPersistenceContextManager) this.kruntime.getEnvironment() .get( EnvironmentName.PERSISTENCE_CONTEXT_MANAGER )) .getProcessPersistenceContext(); // @PrePersist added to ProcessInstanceInfo because of this context.persist( processInstanceInfo ); ((org.jbpm.process.instance.ProcessInstance) processInstance).setId( processInstanceInfo.getId() ); processInstanceInfo.updateLastReadDate(); internalAddProcessInstance(processInstance); } We think after that persist sentence, the entity manager would have to run a flush sentence for the process instance is inserted into database and get the ID. Greets.
_______________________________________________ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users