Bill, When using persistence, you should make sure that all modifications to the process instances are executed through the session, as that will make sure they are performed in a transaction and that the changes are persisted afterwards.
Therefore, you should not change a process instance that you retrieved using getProcessInstance(id). In this case, you should use ksession.signalEvent(type, event, id) instead of calling signalEvent on the process instance itself. You'll need to update to the latest trunk though, as I only just added this method to drools-api (the implementation has been in drools-core for some time now but the method was apparently not added to drools-api yet). Let me know if you still have issues when using this method to signal events. Kris Quoting Bill Tarr <[email protected]>: > After re-loading a session, and trying to send it an Event, I get the > following NullPointerException: > > java.lang.NullPointerException > at > org.drools.impl.StatefulKnowledgeSessionImpl$ProcessEventListenerWrapper.beforeRuleFlowNodeTriggered(StatefulKnowledgeSessionImpl.java:674) > at > org.drools.event.RuleFlowEventSupport.fireBeforeRuleFlowNodeTriggered(RuleFlowEventSupport.java:147) > at > org.drools.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:110) > at > org.drools.workflow.instance.node.EventNodeInstance.signalEvent(EventNodeInstance.java:50) > at > org.drools.workflow.instance.impl.WorkflowProcessInstanceImpl.signalEvent(WorkflowProcessInstanceImpl.java:272) > at > com.csatp.svc.rulesmgr.claim.ClaimsDemoJpaTest.validateDocumentWorkflow2(ClaimsDemoJpaTest.java:209) > > My code is pretty straightforward: > > StatefulKnowledgeSession session = > JPAKnowledgeService.loadStatefulKnowledgeSession( 1, knowledgeBase, > null, env ); > ProcessInstance process = session.getProcessInstance(2); > process.signalEvent("ReceiveDocsEvent", null); > > that same code (and Flow) works on a session created from > knowledgeBase.newStatefulKnowledgeSession(); > > This is difficult for me to debug, but here's what I have: > > In > org.drools.event.RuleFlowEventSupport.fireBeforeRuleFlowNodeTriggered(), > the code is getting listeners: > > final Iterator<RuleFlowEventListener> iter = > getEventListenersIterator(); > > then iterating over them. In the session created from a regular > knowledgeBase, "iter" has the following values > > iter = {java.util.concurrent.CopyOnWriteArrayList$COWIterator @ > 3411} > snapshot = {java.lang.Object[2] @ 3416} > [0] = {org.drools.audit.WorkingMemoryFileLogger @ 3417} > events = {java.util.ArrayList @ 3419} size = 77 > fileName = {java.lang.String @ 3420}"log/claimsdemo" > maxEventsInMemory = 1000 > nbOfFile = 0 > split = true > initialized = false > filters = {java.util.ArrayList @ 3421} size = 0 > [1] = > {org.drools.impl.StatefulKnowledgeSessionImpl$ProcessEventListenerWrapper > @ 3418} > listener = > {com.csatp.svc.rulesmgr.claim.TrackingProcessEventListener @ 3396} > > While the session created using JPAKnowledgeService has the following > values for "iter" > > iter = {java.util.concurrent.CopyOnWriteArrayList$COWIterator @ > 3803} > snapshot = {java.lang.Object[1] @ 3805} > [0] = > {org.drools.impl.StatefulKnowledgeSessionImpl$ProcessEventListenerWrapper > @ 3806} > listener = null > > I can see that the EventListeners should be setup in > AbstractEventSupport and it's implementing classes, > and they are clearly missing, but I'm not sure where this is going > wrong. > > I'll gladly fix this, but just don't know where to start, if you have > any ideas that can help, I'd greatly appreciate it! > > Bill > > > > > _______________________________________________ > rules-users mailing list > [email protected] > https://lists.jboss.org/mailman/listinfo/rules-users > Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm _______________________________________________ rules-users mailing list [email protected] https://lists.jboss.org/mailman/listinfo/rules-users
