[rules-users] Some Problem with drools-persistence-jpa Library

Kris Verlaenen kris.verlaenen at cs.kuleuven.be
Sun Nov 7 19:12:21 EST 2010


Hi,

If you use persistence, you should use ksession.signalEvent(type, event, 
processInstanceId) instead of signaling the process instance itself.  
The reason is that, if you're using persistence, the state of the 
process instance is stored in the database after processing and the 
process instance is disconnected (that is why the working memory is 
null).  The process instance object that you are receiving is just a 
value object (and can for example be sent to a remote machine like the 
client side).  If you use the signalEvent method on the session, the 
process instance will be reloaded and reconnect again, so I think that 
should solve your issue.

Kris

tangrui.cn at gmail.com wrote:
> And another tip is that after ksession.startProcess, I get a 
> ProcessInstance pi, but
>
> ProcessInstance pi = ksession.startProcess("com.zyeeda.system.TestFlow");
> org.drools.process.instance.ProcessInstance pi2 = 
> (org.drools.process.instance.ProcessInstance) pi;
> pi2.getWorkingMemory() // this one returns null
>
> Is this a bug or my usage problem?
>
> On Sun, Nov 7, 2010 at 5:51 PM, tangrui.cn 
> <http://tangrui.cn>@gmail.com <http://gmail.com> <tangrui.cn 
> <http://tangrui.cn>@gmail.com <http://gmail.com>> wrote:
>
>     Hi list,
>
>     The attachment is a very simple test case to demonstrate an
>     application using Drools Persistence JPA (5.1.1).
>
>     Usage:
>
>     1. set up a mysql database called framework
>     2. set the user/password are root/root (or change the
>     bitronix-datasources.properties file)
>     3. run maven test
>
>     The core lines are as following:
>
>     StatefulKnowledgeSession ksession =
>     JPAKnowledgeService.newStatefulKnowledgeSession(kbase, conf, env);
>     ProcessInstance pi =
>     ksession.startProcess("com.zyeeda.system.TestFlow");
>     pi.signalEvent("signal", "goon");
>
>     When executing the 3rd line, an exception occurred
>
>     java.lang.NullPointerException
>         at
>     org.drools.process.instance.impl.ProcessInstanceImpl.getProcess(ProcessInstanceImpl.java:67)
>         at
>     org.drools.workflow.instance.impl.WorkflowProcessInstanceImpl.getWorkflowProcess(WorkflowProcessInstanceImpl.java:185)
>         at
>     org.drools.workflow.instance.impl.WorkflowProcessInstanceImpl.signalEvent(WorkflowProcessInstanceImpl.java:346)
>         at com.zyeeda.test.AppTest.testProcessPersistence(AppTest.java:84)
>
>     I've headed into the code and find that some working memory
>     related to the ProcessInstanceImpl is null.
>     (drools-core/src/main/java/org/drools/process/instance/impl/ProcessInstanceImpl.java)
>
>     But I cannot get why this does happen. Please give me some tips.
>
>     I tried to google some solutions, but find only this one
>     (http://drools-java-rules-engine.46999.n3.nabble.com/Drools-Flow-Events-Not-Working-td1453738.html),
>     but it seems that he solved this problem by using a custom command.
>
>     Thank you!
>
>     -- 
>     唐睿
>
>
>
>
> -- 
> 唐睿
> ------------------------------------------------------------------------
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>   




More information about the rules-users mailing list