<br><font size=2 face="sans-serif">Kris,</font>
<br>
<br><font size=2 face="sans-serif">Many thanks for your continued help.
I updated to the latest trunk, and replaced my milestone node with a state
node as suggested, and the process instance completed as required.</font>
<br>
<br><font size=2 face="sans-serif">Two things I noticed:</font>
<br>
<br><font size=2 face="sans-serif">1. The state node isn't currently available
in the palette of the Eclipse plug-in graphical editor - presumably it
will be in the final release of 5.1?</font>
<br>
<br><font size=2 face="sans-serif">2. If the ID of my process definition
contains a hyphen, then the process does not complete. If you change the
id in ruleflow.rf in the test case I sent you from &quot;com.test.ruleflow&quot;
to &quot;com.test.ruleflow-x&quot; (and change the argument to ksession.startProcess()
in PersistenceTest.java), you'll see that the process doesn't complete.
Any ideas as to why this is happening?<br>
</font>
<br><font size=2 face="sans-serif">Anyway, thank you again.</font>
<br>
<br><font size=2 face="sans-serif">Regards,</font>
<br>
<br><font size=2 face="sans-serif">Alan</font>
<p>
<br>
<br>
<br>
<table width=100%>
<tr valign=top>
<td width=40%><font size=1 face="sans-serif"><b>Kris Verlaenen &lt;kris.verlaenen@cs.kuleuven.be&gt;</b>
</font>
<p><font size=1 face="sans-serif">07/11/2009 01:40</font>
<td width=59%>
<table width=100%>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">To</font></div>
<td><font size=1 face="sans-serif">Alan.Gairey@tessella.com</font>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">cc</font></div>
<td><font size=1 face="sans-serif">rules-users@lists.jboss.org</font>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">Subject</font></div>
<td><font size=1 face="sans-serif">Re: [rules-users] [droolsflow] Code-based
constraints for EventWait nodes - is this possible?</font></table>
<br>
<table>
<tr valign=top>
<td>
<td></table>
<br></table>
<br>
<br>
<br><tt><font size=2>Alan,<br>
<br>
The problem you are seeing is caused by the fact that you are retrieving<br>
the process instance in the work item manager. &nbsp;There's nothing wrong<br>
with that, but there is an issue that the process instance that is being<br>
executed was not yet registered, so the process instance will be<br>
retrieved from db, but this is the old version.<br>
<br>
Also note that you should try the new state node instead of the old<br>
milestone node (aka event wait node), as the new state node is more<br>
powerful but also offers the same features as the milestone node. &nbsp;For<br>
example, your milestone node would be the same as:<br>
 &nbsp; &nbsp;&lt;state id=&quot;10&quot; name=&quot;Retry?&quot; x=&quot;382&quot;
y=&quot;164&quot; width=&quot;80&quot; height=&quot;40&quot; &gt;<br>
 &nbsp; &nbsp; &nbsp;&lt;constraints&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp;&lt;constraint toNodeId=&quot;9&quot; name=&quot;retry&quot;
priority=&quot;1&quot;<br>
&gt;SimpleFact(retry == true)&lt;/constraint&gt;<br>
 &nbsp; &nbsp; &nbsp;&lt;/constraints&gt;<br>
 &nbsp; &nbsp;&lt;/state&gt;<br>
<br>
Updating to the latest trunk and using the state node should fix your issue.<br>
<br>
Kris<br>
<br>
Quoting Alan.Gairey@tessella.com:<br>
<br>
&gt; Kris,<br>
&gt; <br>
&gt; Thanks yes - the null check fixes the NPE I was seeing.<br>
&gt; <br>
&gt; Unfortunately, I now have a more difficult problem. In my work item
<br>
&gt; handler, I use the following code to get the ID of a work item in
the<br>
&gt; rule <br>
&gt; flow (i.e. the .rf file itself) given a <br>
&gt; org.drools.runtime.process.WorkItem instance:<br>
&gt; <br>
&gt; &nbsp; &nbsp; private long getCurrentNodeId(WorkItem workItem) {<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; ProcessInstance processInstance = <br>
&gt; ksession.getProcessInstance(workItem.getProcessInstanceId());<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; if (processInstance instanceof WorkflowProcessInstanceImpl)<br>
&gt; {<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Collection&lt;NodeInstance&gt;
nodeInstances = <br>
&gt; ((WorkflowProcessInstanceImpl) processInstance).getNodeInstances();<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (NodeInstance nodeInstance
: nodeInstances) {<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; System.out.println(String.format(&quot;Node
instance: %s&quot;,<br>
&gt; <br>
&gt; nodeInstance));<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (nodeInstance
instanceof WorkItemNodeInstance) {<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
WorkItemNodeInstance workItemNodeInstance = <br>
&gt; (WorkItemNodeInstance) nodeInstance;<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
if (workItemNodeInstance.getWorkItem() ==<br>
&gt; workItem) {<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; return workItemNodeInstance.getNodeId();<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
}<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; }<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; throw new RuntimeException(String.format(&quot;Error
determining<br>
&gt; node <br>
&gt; ID for work item: %s&quot;, workItem.toString()));<br>
&gt; &nbsp; &nbsp; }<br>
&gt; The work item in the attached test case, the first time it executes<br>
&gt; sets a <br>
&gt; property on a fact in memory that causes a subsequent Split node to<br>
&gt; send <br>
&gt; the flow to an Event Wait. The code in the overall main() method (in<br>
&gt; <br>
&gt; PersistenceTest.java) then updates the fact in memory so that the<br>
&gt; Event <br>
&gt; Wait's constraint is satisfied, and the work item node is executed<br>
&gt; again. <br>
&gt; The second time around, it sets the property on the fact in memory
so<br>
&gt; that <br>
&gt; the subsequent Split node sends the flow to its end. (I hope this<br>
&gt; makes <br>
&gt; sense; looking at the rule flow in the test case should show you what<br>
&gt; I'm <br>
&gt; trying to do.)<br>
&gt; <br>
&gt; If I execute the test case with my session created using the code:<br>
&gt; &nbsp; StatefulKnowledgeSession ksession =<br>
&gt; kbase.newStatefulKnowledgeSession();<br>
&gt; everything works as I would expect, and the output from the <br>
&gt; System.out.println() statement in my getCurrentNodeId() method above<br>
&gt; is:<br>
&gt; &nbsp; Node instance: <br>
&gt; org.drools.workflow.instance.node.WorkItemNodeInstance@125d568<br>
&gt; &nbsp; Node instance: <br>
&gt; org.drools.workflow.instance.node.WorkItemNodeInstance@37a04c<br>
&gt; <br>
&gt; However, if I use JPA persistence:<br>
&gt; &nbsp; StatefulKnowledgeSession ksession = <br>
&gt; JPAKnowledgeService.newStatefulKnowledgeSession(kbase, null, env);<br>
&gt; then the RuntimeException in getCurrentNodeId() is thrown, and the<br>
&gt; output <br>
&gt; is:<br>
&gt; &nbsp; Node instance: <br>
&gt; org.drools.workflow.instance.node.WorkItemNodeInstance@2209db<br>
&gt; &nbsp; Node instance: <br>
&gt; org.drools.workflow.instance.node.MilestoneNodeInstance@d8fd1a<br>
&gt; Somehow it seems as though the node instance isn't quite synchronised<br>
&gt; with <br>
&gt; the overall state when using JPA persistence.<br>
&gt; Any help you could give me here would be very much appreciated.<br>
&gt; Regards,<br>
&gt; Alan<br>
&gt; <br>
&gt; <br>
&gt; <br>
&gt; <br>
&gt; Kris Verlaenen &lt;kris.verlaenen@cs.kuleuven.be&gt; <br>
&gt; 30/10/2009 20:10<br>
&gt; <br>
&gt; To<br>
&gt; Alan.Gairey@tessella.com<br>
&gt; cc<br>
&gt; <br>
&gt; Subject<br>
&gt; Re: [rules-users] [droolsflow] Code-based constraints for EventWait<br>
&gt; nodes <br>
&gt; - is this possible?<br>
&gt; <br>
&gt; <br>
&gt; <br>
&gt; <br>
&gt; <br>
&gt; <br>
&gt; Alan, <br>
&gt; <br>
&gt; Thanks, this indeed seems to be the issue. &nbsp;I have changed this
on<br>
&gt; trunk. &nbsp;Does adding this null check solve your issue?<br>
&gt; <br>
&gt; Thx,<br>
&gt; Kris<br>
&gt; <br>
&gt; Quoting Alan.Gairey@tessella.com:<br>
&gt; <br>
&gt; &gt; Kris,<br>
&gt; &gt; <br>
&gt; &gt; Some more information: the NullPointerException from<br>
&gt; GetObjectCommand<br>
&gt; &gt; is <br>
&gt; &gt; thrown by the line:<br>
&gt; &gt; <br>
&gt; &gt; <br>
&gt; &gt;<br>
&gt;<br>
((StatefulKnowledgeSessionImpl)ksession).session.getExecutionResult().getResults().put(<br>
&gt; &gt; <br>
&gt; &gt; this.outIdentifier,<br>
&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;object );<br>
&gt; &gt; <br>
&gt; &gt; Method getExecutionResult() is returning null. Debugging my test<br>
&gt; &gt; case, I <br>
&gt; &gt; also notice that this.outIdentifier is also null.<br>
&gt; &gt; <br>
&gt; &gt; I then had a look at the GetObjectsCommand class; in its execute<br>
&gt; &gt; method, <br>
&gt; &gt; there is a line similar to that above. However, it is contained<br>
&gt; &gt; within an <br>
&gt; &gt; if block that checks this.outIdentifier is not null:<br>
&gt; &gt; <br>
&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; if ( this.outIdentifier != null )
{<br>
&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; List objects = new
ArrayList( col );<br>
&gt; &gt; <br>
&gt; &gt; <br>
&gt; &gt;<br>
&gt;<br>
((StatefulKnowledgeSessionImpl)ksession).session.getExecutionResult().getResults().put(<br>
&gt; &gt; <br>
&gt; &gt; this.outIdentifier, objects );<br>
&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; }<br>
&gt; &gt; <br>
&gt; &gt; If something similar was done in GetObjectCommand, presumably
this<br>
&gt; &gt; would <br>
&gt; &gt; fix my problem?<br>
&gt; &gt; <br>
&gt; &gt; Hope this is of some use - regards,<br>
&gt; &gt; <br>
&gt; &gt; Alan<br>
&gt; &gt; <br>
&gt; &gt; <br>
&gt; &gt; <br>
&gt; &gt; <br>
&gt; &gt; Alan.Gairey@tessella.com <br>
&gt; &gt; Sent by: rules-users-bounces@lists.jboss.org<br>
&gt; &gt; 29/10/2009 17:35<br>
&gt; &gt; Please respond to<br>
&gt; &gt; Rules Users List &lt;rules-users@lists.jboss.org&gt;<br>
&gt; &gt; <br>
&gt; &gt; <br>
&gt; &gt; To<br>
&gt; &gt; Kris Verlaenen &lt;kris.verlaenen@cs.kuleuven.be&gt;<br>
&gt; &gt; cc<br>
&gt; &gt; Rules Users List &lt;rules-users@lists.jboss.org&gt;<br>
&gt; &gt; Subject<br>
&gt; &gt; Re: [rules-users] [droolsflow] Code-based constraints for<br>
&gt; EventWait<br>
&gt; &gt; nodes <br>
&gt; &gt; - is this possible?<br>
&gt; &gt; <br>
&gt; &gt; <br>
&gt; &gt; <br>
&gt; &gt; <br>
&gt; &gt; <br>
&gt; &gt; <br>
&gt; &gt; <br>
&gt; &gt; Kris,<br>
&gt; &gt; <br>
&gt; &gt; Thanks - making the class SimpleFact serializable fixed that
error.<br>
&gt; <br>
&gt; &gt; <br>
&gt; &gt; However, I now have a new problem: I have a rule flow containing
a<br>
&gt; &gt; work <br>
&gt; &gt; item - the handler attempts to update the SimpleFact instance
in<br>
&gt; &gt; memory <br>
&gt; &gt; before completing the task. The code in the executeWorkItem method<br>
&gt; is<br>
&gt; &gt; as <br>
&gt; &gt; follows: <br>
&gt; &gt; <br>
&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; Collection&lt;FactHandle&gt; factHandles
=<br>
&gt; &gt; ksession.getFactHandles(new <br>
&gt; &gt; ObjectFilter() { <br>
&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public boolean accept(Object
object) { <br>
&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return
(object instanceof SimpleFact); <br>
&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } <br>
&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; }); <br>
&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; for (Iterator&lt;FactHandle&gt; iterator
=<br>
&gt; factHandles.iterator();<br>
&gt; &gt; <br>
&gt; &gt; iterator.hasNext(); ) { <br>
&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FactHandle factHandle
= iterator.next(); <br>
&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SimpleFact fact = (SimpleFact)<br>
&gt; &gt; ksession.getObject(factHandle); <br>
&gt; &gt; <br>
&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fact.setStatus(&quot;Error&quot;);
<br>
&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ksession.update(factHandle,
fact); <br>
&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; } <br>
&gt; &gt; <br>
&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; workItemManager.completeWorkItem(workItem.getId(),
null); <br>
&gt; &gt; <br>
&gt; &gt; The call to getObject() causes the following exception to be<br>
&gt; thrown:<br>
&gt; &gt; <br>
&gt; &gt; <br>
&gt; &gt; java.lang.NullPointerException <br>
&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; at <br>
&gt; &gt;<br>
&gt;<br>
org.drools.command.runtime.rule.GetObjectCommand.execute(GetObjectCommand.java:35)<br>
&gt; &gt; <br>
&gt; &gt; <br>
&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; at <br>
&gt; &gt;<br>
&gt;<br>
org.drools.persistence.session.SingleSessionCommandService.execute(SingleSessionCommandService.java:254)<br>
&gt; &gt; <br>
&gt; &gt; <br>
&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; at <br>
&gt; &gt;<br>
&gt;<br>
org.drools.command.impl.CommandBasedStatefulKnowledgeSession.getObject(CommandBasedStatefulKnowledgeSession.java:369)<br>
&gt; &gt; <br>
&gt; &gt; <br>
&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; at <br>
&gt; &gt;<br>
&gt;<br>
com.test.StatusChangeWorkItemHandler.executeWorkItem(StatusChangeWorkItemHandler.java:37)<br>
&gt; &gt; <br>
&gt; &gt; <br>
&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; ... <br>
&gt; &gt; <br>
&gt; &gt; I've attached another test case to illustrate the problem. <br>
&gt; &gt; <br>
&gt; &gt; <br>
&gt; &gt; <br>
&gt; &gt; Once again, my sincere thanks for helping me with this. <br>
&gt; &gt; <br>
&gt; &gt; Regards, <br>
&gt; &gt; <br>
&gt; &gt; Alan <br>
&gt; &gt; <br>
&gt; &gt; <br>
&gt; &gt; <br>
&gt; &gt; Kris Verlaenen &lt;kris.verlaenen@cs.kuleuven.be&gt; <br>
&gt; &gt; 29/10/2009 12:00 <br>
&gt; &gt; <br>
&gt; &gt; <br>
&gt; &gt; To<br>
&gt; &gt; Alan.Gairey@tessella.com <br>
&gt; &gt; cc<br>
&gt; &gt; Rules Users List &lt;rules-users@lists.jboss.org&gt; <br>
&gt; &gt; Subject<br>
&gt; &gt; Re: [rules-users] [droolsflow] Code-based constraints for<br>
&gt; EventWait<br>
&gt; &gt; nodes <br>
&gt; &gt; - is this possible?<br>
&gt; &gt; <br>
&gt; &gt; <br>
&gt; &gt; <br>
&gt; &gt; <br>
&gt; &gt; <br>
&gt; &gt; <br>
&gt; &gt; <br>
&gt; &gt; <br>
&gt; &gt; Alan,<br>
&gt; &gt; <br>
&gt; &gt; The cause of the rollback of the transaction is this:<br>
&gt; &gt; Caused by: java.io.NotSerializableException: com.test.SimpleFact<br>
&gt; &gt; <br>
&gt; &gt; The reason is that, if you use persistence for your session,
the<br>
&gt; &gt; persister will try to save all runtime state of the engine. &nbsp;This<br>
&gt; &gt; does<br>
&gt; &gt; not only include process instances, but also rule-related state.
<br>
&gt; By<br>
&gt; &gt; default, this also includes the data inserted in the memory.
&nbsp;We<br>
&gt; &gt; support<br>
&gt; &gt; two strategies for storing this data: serialization of the data<br>
&gt; &gt; (default) or JPA-based storage of entities (by reference). &nbsp;In<br>
&gt; this<br>
&gt; &gt; case, the persister is trying to serialize the test object you<br>
&gt; &gt; inserted<br>
&gt; &gt; and fails. &nbsp;Making it serializable should fix this.<br>
&gt; &gt; <br>
&gt; &gt; Kris<br>
&gt; &gt; <br>
&gt; &gt; Quoting Alan.Gairey@tessella.com:<br>
&gt; &gt; <br>
&gt; &gt; &gt; Kris,<br>
&gt; &gt; &gt; <br>
&gt; &gt; &gt; I've attached a simple test case (transaction manager, data<br>
&gt; &gt; source,<br>
&gt; &gt; &gt; etc. <br>
&gt; &gt; &gt; are configured via Spring). The error is thrown on line:<br>
&gt; &gt; &gt; <br>
&gt; &gt; &gt; ksession.insert(new SimpleFact());<br>
&gt; &gt; &gt; <br>
&gt; &gt; &gt; If this line is commented out, the rule flow executes without<br>
&gt; &gt; error.<br>
&gt; &gt; &gt; <br>
&gt; &gt; &gt; <br>
&gt; &gt; &gt; <br>
&gt; &gt; &gt; Many thanks for looking at this.<br>
&gt; &gt; &gt; <br>
&gt; &gt; &gt; Regards,<br>
&gt; &gt; &gt; <br>
&gt; &gt; &gt; Alan<br>
&gt; &gt; &gt; <br>
&gt; &gt; &gt; <br>
&gt; &gt; &gt; <br>
&gt; &gt; &gt; <br>
&gt; &gt; &gt; Kris Verlaenen &lt;kris.verlaenen@cs.kuleuven.be&gt; <br>
&gt; &gt; &gt; 28/10/2009 10:40<br>
&gt; &gt; &gt; <br>
&gt; &gt; &gt; To<br>
&gt; &gt; &gt; Alan.Gairey@tessella.com<br>
&gt; &gt; &gt; cc<br>
&gt; &gt; &gt; Rules Users List &lt;rules-users@lists.jboss.org&gt;<br>
&gt; &gt; &gt; Subject<br>
&gt; &gt; &gt; Re: [rules-users] [droolsflow] Code-based constraints for<br>
&gt; &gt; EventWait<br>
&gt; &gt; &gt; nodes <br>
&gt; &gt; &gt; - is this possible?<br>
&gt; &gt; &gt; <br>
&gt; &gt; &gt; <br>
&gt; &gt; &gt; <br>
&gt; &gt; &gt; <br>
&gt; &gt; &gt; <br>
&gt; &gt; &gt; <br>
&gt; &gt; &gt; Alan,<br>
&gt; &gt; &gt; <br>
&gt; &gt; &gt; Could you send me the entire output / stack trace (as the<br>
&gt; rollback<br>
&gt; &gt; &gt; of<br>
&gt; &gt; &gt; the transaction is usually caused by another exception)?<br>
&gt; &gt; &gt; <br>
&gt; &gt; &gt; Or a simple test case that shows the error, so I can take
a<br>
&gt; look?<br>
&gt; &gt; &gt; <br>
&gt; &gt; &gt; Thx,<br>
&gt; &gt; &gt; Kris<br>
&gt; &gt; &gt; <br>
&gt; &gt; &gt; Quoting Alan.Gairey@tessella.com:<br>
&gt; &gt; &gt; <br>
&gt; &gt; &gt; &gt; Kris,<br>
&gt; &gt; &gt; &gt; <br>
&gt; &gt; &gt; &gt; After posting my last question, I quickly came to the
same<br>
&gt; &gt; &gt; conclusion<br>
&gt; &gt; &gt; &gt; as <br>
&gt; &gt; &gt; &gt; you, so I'm now using a rule-based constraint in my
EventWait<br>
&gt; &gt; &gt; node.<br>
&gt; &gt; &gt; &gt; <br>
&gt; &gt; &gt; &gt; This however has presented a different problem. If
I create my<br>
&gt; &gt; &gt; &gt; session <br>
&gt; &gt; &gt; &gt; from JPAKnowledgeService, then when I try to insert
my fact<br>
&gt; into<br>
&gt; &gt; &gt; the<br>
&gt; &gt; &gt; &gt; <br>
&gt; &gt; &gt; &gt; session, I get the following error:<br>
&gt; &gt; &gt; &gt; <br>
&gt; &gt; &gt; &gt; bitronix.tm.internal.BitronixRollbackException: transaction<br>
&gt; was<br>
&gt; &gt; &gt; &gt; marked as <br>
&gt; &gt; &gt; &gt; rollback only and has been rolled back<br>
&gt; &gt; &gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; at <br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt;<br>
&gt; bitronix.tm.BitronixTransaction.commit(BitronixTransaction.java:153)<br>
&gt; &gt; &gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; at <br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt;<br>
&gt;<br>
bitronix.tm.BitronixTransactionManager.commit(BitronixTransactionManager.java:96)<br>
&gt; &gt; &gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; at <br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt;<br>
&gt;<br>
org.drools.persistence.session.SingleSessionCommandService.execute(SingleSessionCommandService.java:258)<br>
&gt; &gt; &gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; at <br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt;<br>
&gt;<br>
org.drools.command.impl.CommandBasedStatefulKnowledgeSession.insert(CommandBasedStatefulKnowledgeSession.java:305)<br>
&gt; &gt; &gt; &gt; (Everything works fine if I create my session from
the<br>
&gt; knowledge<br>
&gt; &gt; &gt; base<br>
&gt; &gt; &gt; &gt; - <br>
&gt; &gt; &gt; &gt; i.e. with no state persistence.)<br>
&gt; &gt; &gt; &gt; Prior to using a rule-based constraint (with no call
to <br>
&gt; &gt; &gt; &gt; CommandBasedStatefulKnowledgeSession.insert), the session<br>
&gt; &gt; created<br>
&gt; &gt; &gt; &gt; from <br>
&gt; &gt; &gt; &gt; JPAKnowledgeService worked OK.<br>
&gt; &gt; &gt; &gt; I'm using the default JPA configuration from the Drools<br>
&gt; &gt; &gt; documentation<br>
&gt; &gt; &gt; &gt; <br>
&gt; &gt; &gt; &gt; (persisting to H2 database, etc.).<br>
&gt; &gt; &gt; &gt; Any ideas what might be causing the problem?<br>
&gt; &gt; &gt; &gt; Many thanks,<br>
&gt; &gt; &gt; &gt; Alan<br>
&gt; &gt; &gt; &gt; <br>
&gt; &gt; &gt; &gt; <br>
&gt; &gt; &gt; &gt; <br>
&gt; &gt; &gt; &gt; <br>
&gt; &gt; &gt; &gt; Kris Verlaenen &lt;kris.verlaenen@cs.kuleuven.be&gt;
<br>
&gt; &gt; &gt; &gt; 23/10/2009 03:00<br>
&gt; &gt; &gt; &gt; <br>
&gt; &gt; &gt; &gt; To<br>
&gt; &gt; &gt; &gt; Rules Users List &lt;rules-users@lists.jboss.org&gt;,<br>
&gt; &gt; &gt; &gt; Alan.Gairey@tessella.com<br>
&gt; &gt; &gt; &gt; cc<br>
&gt; &gt; &gt; &gt; Rules Users List &lt;rules-users@lists.jboss.org&gt;<br>
&gt; &gt; &gt; &gt; Subject<br>
&gt; &gt; &gt; &gt; Re: [rules-users] [droolsflow] Code-based constraints
for<br>
&gt; &gt; &gt; EventWait<br>
&gt; &gt; &gt; &gt; nodes <br>
&gt; &gt; &gt; &gt; - is this possible?<br>
&gt; &gt; &gt; &gt; <br>
&gt; &gt; &gt; &gt; <br>
&gt; &gt; &gt; &gt; <br>
&gt; &gt; &gt; &gt; <br>
&gt; &gt; &gt; &gt; <br>
&gt; &gt; &gt; &gt; <br>
&gt; &gt; &gt; &gt; No, the constraint of an EventWait node (or the State
node in<br>
&gt; &gt; &gt; Drools<br>
&gt; &gt; &gt; &gt; 5.1) can only be rule-based. &nbsp;The reason for this
is that the<br>
&gt; &gt; rule<br>
&gt; &gt; &gt; &gt; engine knows when to re-evaluates rules (based on the<br>
&gt; evailable<br>
&gt; &gt; &gt; &gt; input).<br>
&gt; &gt; &gt; &gt; &nbsp;If you would use a code-based constraint, the
engine would<br>
&gt; have<br>
&gt; &gt; &gt; no<br>
&gt; &gt; &gt; &gt; idea<br>
&gt; &gt; &gt; &gt; when this code constraint might become true (if it
was false<br>
&gt; at<br>
&gt; &gt; &gt; the<br>
&gt; &gt; &gt; &gt; start). &nbsp;Only constant re-evaluation of the code
constraint<br>
&gt; &gt; could<br>
&gt; &gt; &gt; &gt; achieve this (which would be tremendously inefficient).
&nbsp;Could<br>
&gt; &gt; you<br>
&gt; &gt; &gt; &gt; explain why you would like to have this behaviour?
&nbsp;Maybe<br>
&gt; there<br>
&gt; &gt; is<br>
&gt; &gt; &gt; &gt; an<br>
&gt; &gt; &gt; &gt; alternative way to model this.<br>
&gt; &gt; &gt; &gt; <br>
&gt; &gt; &gt; &gt; To change the value of a variable from inside the process<br>
&gt; (using<br>
&gt; &gt; &gt; an<br>
&gt; &gt; &gt; &gt; action), simply use kcontext.setVariable(name, value).
&nbsp;We do<br>
&gt; &gt; not<br>
&gt; &gt; &gt; &gt; recommend manually changing the value of a process
variable<br>
&gt; from<br>
&gt; &gt; &gt; &gt; outside<br>
&gt; &gt; &gt; &gt; the engine. &nbsp;Again, could you explain why you
would like to<br>
&gt; have<br>
&gt; &gt; &gt; &gt; this<br>
&gt; &gt; &gt; &gt; functionality?<br>
&gt; &gt; &gt; &gt; <br>
&gt; &gt; &gt; &gt; Kris<br>
&gt; &gt; &gt; &gt; <br>
&gt; &gt; &gt; &gt; Quoting Alan.Gairey@tessella.com:<br>
&gt; &gt; &gt; &gt; <br>
&gt; &gt; &gt; &gt; &gt; Can the constraint for an EventWait node in a
flow be<br>
&gt; &gt; code-based<br>
&gt; &gt; &gt; &gt; &gt; (rather <br>
&gt; &gt; &gt; &gt; &gt; than rule-based)? The Eclipse plug-in (v 5.0.1)
doesn't<br>
&gt; allow<br>
&gt; &gt; &gt; this<br>
&gt; &gt; &gt; &gt; to<br>
&gt; &gt; &gt; &gt; &gt; be <br>
&gt; &gt; &gt; &gt; &gt; specified, unlike say for a Split node, although
the<br>
&gt; relevant<br>
&gt; &gt; &gt; XML<br>
&gt; &gt; &gt; &gt; can<br>
&gt; &gt; &gt; &gt; &gt; of <br>
&gt; &gt; &gt; &gt; &gt; course be edited.<br>
&gt; &gt; &gt; &gt; &gt; Trying to load such a process flow results in
a<br>
&gt; &gt; &gt; &gt; NullPointerException,<br>
&gt; &gt; &gt; &gt; &gt; <br>
&gt; &gt; &gt; &gt; &gt; because the constraint is always interpreted as
a rule.<br>
&gt; &gt; &gt; &gt; &gt; <br>
&gt; &gt; &gt; &gt; &gt; Ideally what I'd like to do is have an EventWait
node where<br>
&gt; &gt; the<br>
&gt; &gt; &gt; &gt; &gt; constraint <br>
&gt; &gt; &gt; &gt; &gt; tests the value of a process variable. This then
leads me to<br>
&gt; &gt; &gt; &gt; another<br>
&gt; &gt; &gt; &gt; &gt; <br>
&gt; &gt; &gt; &gt; &gt; question; is there a way of setting the value
of a process<br>
&gt; &gt; &gt; &gt; variable<br>
&gt; &gt; &gt; &gt; &gt; via <br>
&gt; &gt; &gt; &gt; &gt; the Drools Flow API?<br>
&gt; &gt; &gt; &gt; &gt; <br>
&gt; &gt; &gt; &gt; &gt; Thanks in advance for any help,<br>
&gt; &gt; &gt; &gt; &gt; <br>
&gt; &gt; &gt; &gt; &gt; Alan<br>
&gt; &gt; &gt; &gt; &gt; Tessella plc<br>
&gt; &gt; &gt; &gt; &gt; 26 The Quadrant, Abingdon Science Park, Abingdon,<br>
&gt; Oxfordshire,<br>
&gt; &gt; &gt; &gt; OX14<br>
&gt; &gt; &gt; &gt; &gt; 3YS<br>
&gt; &gt; &gt; &gt; &gt; E: Alan.Gairey@tessella.com, T: +44 (0)1235 555511,
F: +44<br>
&gt; &gt; &gt; (0)1235<br>
&gt; &gt; &gt; &gt; &gt; 553301<br>
&gt; &gt; &gt; &gt; &gt; www.tessella.com &nbsp; &nbsp;Registered in England
No. 1466429<br>
&gt; &gt; &gt; &gt; &gt; <br>
&gt; &gt; &gt; &gt; &gt; This message is commercial in confidence and may
be<br>
&gt; &gt; privileged.<br>
&gt; &gt; &gt; It<br>
&gt; &gt; &gt; &gt; is<br>
&gt; &gt; &gt; &gt; &gt; <br>
&gt; &gt; &gt; &gt; &gt; intended for the addressee(s) only. Access to
this message<br>
&gt; by<br>
&gt; &gt; &gt; &gt; anyone<br>
&gt; &gt; &gt; &gt; &gt; else <br>
&gt; &gt; &gt; &gt; &gt; is unauthorized and strictly prohibited. If you
have<br>
&gt; received<br>
&gt; &gt; &gt; this<br>
&gt; &gt; &gt; &gt; &gt; message <br>
&gt; &gt; &gt; &gt; &gt; in error, please inform the sender immediately.
Please note<br>
&gt; &gt; that<br>
&gt; &gt; &gt; &gt; &gt; messages <br>
&gt; &gt; &gt; &gt; &gt; sent or received by the Tessella e-mail system
may be<br>
&gt; &gt; monitored<br>
&gt; &gt; &gt; &gt; and<br>
&gt; &gt; &gt; &gt; &gt; stored <br>
&gt; &gt; &gt; &gt; &gt; in an information retrieval system.<br>
&gt; &gt; &gt; &gt; &gt; <br>
&gt; &gt; &gt; &gt; <br>
&gt; &gt; &gt; &gt; <br>
&gt; &gt; &gt; &gt; <br>
&gt; &gt; &gt; &gt; <br>
&gt; &gt; &gt; &gt; Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm<br>
&gt; &gt; &gt; &gt; <br>
&gt; &gt; &gt; &gt; <br>
&gt; &gt; &gt; <br>
&gt; &gt; &gt; <br>
&gt; &gt; &gt; <br>
&gt; &gt; &gt; <br>
&gt; &gt; &gt; Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm<br>
&gt; &gt; &gt; <br>
&gt; &gt; &gt; <br>
&gt; &gt; <br>
&gt; &gt; <br>
&gt; &gt; <br>
&gt; &gt; <br>
&gt; &gt; Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm<br>
&gt; &gt; [attachment &quot;drools-persistence-test.zip&quot; deleted by
Alan<br>
&gt; &gt; Gairey/Tessella] <br>
&gt; &gt; _______________________________________________<br>
&gt; &gt; rules-users mailing list<br>
&gt; &gt; rules-users@lists.jboss.org<br>
&gt; &gt; https://lists.jboss.org/mailman/listinfo/rules-users<br>
&gt; &gt; <br>
&gt; &gt; </font></tt>
<br><tt><font size=2>&gt; <br>
&gt; <br>
&gt; <br>
&gt; <br>
&gt; Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm<br>
&gt; <br>
&gt; <br>
<br>
<br>
<br>
<br>
Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm<br>
</font></tt>
<br>