[rules-users] [droolsflow] - JPAKnowledgeService - Another Event based NullPointerException

Bill Tarr javatestcase at yahoo.com
Mon Oct 26 14:49:36 EDT 2009


Hi Kris,

OK, I see new the signature in the ProcessRuntime interface:

signalEvent(String type, Object event, long processInstanceId);

I'll try and test that out today.

Thanks for taking the time to fix up the code!

Bill



----- Original Message ----
From: Kris Verlaenen <kris.verlaenen at cs.kuleuven.be>
To: Rules Users List <rules-users at lists.jboss.org>; Bill Tarr <javatestcase at yahoo.com>
Sent: Sun, October 25, 2009 1:53:32 PM
Subject: Re: [rules-users] [droolsflow] - JPAKnowledgeService - Another Event based NullPointerException

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 <javatestcase at yahoo.com>:

> 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
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
> 




Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 




More information about the rules-users mailing list