<br><font size=2 face="sans-serif">Kris,</font>
<br>
<br><font size=2 face="sans-serif">I've attached a simple test case (transaction
manager, data source, etc. are configured via Spring). The error is thrown
on line:</font>
<br>
<br><font size=2 face="sans-serif">ksession.insert(new SimpleFact());</font>
<br>
<br><font size=2 face="sans-serif">If this line is commented out, the rule
flow executes without error.</font>
<br>
<br>
<br>
<br><font size=2 face="sans-serif">Many thanks for looking at this.</font>
<br>
<br><font size=2 face="sans-serif">Regards,<br>
</font>
<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">28/10/2009 10: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 List &lt;rules-users@lists.jboss.org&gt;</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>
Could you send me the entire output / stack trace (as the rollback of<br>
the transaction is usually caused by another exception)?<br>
<br>
Or a simple test case that shows the error, so I can take a look?<br>
<br>
Thx,<br>
Kris<br>
<br>
Quoting Alan.Gairey@tessella.com:<br>
<br>
&gt; Kris,<br>
&gt; <br>
&gt; After posting my last question, I quickly came to the same conclusion<br>
&gt; as <br>
&gt; you, so I'm now using a rule-based constraint in my EventWait node.<br>
&gt; <br>
&gt; This however has presented a different problem. If I create my<br>
&gt; session <br>
&gt; from JPAKnowledgeService, then when I try to insert my fact into the<br>
&gt; <br>
&gt; session, I get the following error:<br>
&gt; <br>
&gt; bitronix.tm.internal.BitronixRollbackException: transaction was<br>
&gt; marked as <br>
&gt; rollback only and has been rolled back<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; at <br>
&gt; bitronix.tm.BitronixTransaction.commit(BitronixTransaction.java:153)<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; at <br>
&gt;<br>
bitronix.tm.BitronixTransactionManager.commit(BitronixTransactionManager.java:96)<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; at <br>
&gt;<br>
org.drools.persistence.session.SingleSessionCommandService.execute(SingleSessionCommandService.java:258)<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; at <br>
&gt;<br>
org.drools.command.impl.CommandBasedStatefulKnowledgeSession.insert(CommandBasedStatefulKnowledgeSession.java:305)<br>
&gt; (Everything works fine if I create my session from the knowledge base<br>
&gt; - <br>
&gt; i.e. with no state persistence.)<br>
&gt; Prior to using a rule-based constraint (with no call to <br>
&gt; CommandBasedStatefulKnowledgeSession.insert), the session created<br>
&gt; from <br>
&gt; JPAKnowledgeService worked OK.<br>
&gt; I'm using the default JPA configuration from the Drools documentation<br>
&gt; <br>
&gt; (persisting to H2 database, etc.).<br>
&gt; Any ideas what might be causing the problem?<br>
&gt; Many thanks,<br>
&gt; Alan<br>
&gt; <br>
&gt; <br>
&gt; <br>
&gt; <br>
&gt; Kris Verlaenen &lt;kris.verlaenen@cs.kuleuven.be&gt; <br>
&gt; 23/10/2009 03:00<br>
&gt; <br>
&gt; To<br>
&gt; Rules Users List &lt;rules-users@lists.jboss.org&gt;,<br>
&gt; Alan.Gairey@tessella.com<br>
&gt; cc<br>
&gt; Rules Users List &lt;rules-users@lists.jboss.org&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; No, the constraint of an EventWait node (or the State node in Drools<br>
&gt; 5.1) can only be rule-based. &nbsp;The reason for this is that the
rule<br>
&gt; engine knows when to re-evaluates rules (based on the evailable<br>
&gt; input).<br>
&gt; &nbsp;If you would use a code-based constraint, the engine would have
no<br>
&gt; idea<br>
&gt; when this code constraint might become true (if it was false at the<br>
&gt; start). &nbsp;Only constant re-evaluation of the code constraint could<br>
&gt; achieve this (which would be tremendously inefficient). &nbsp;Could
you<br>
&gt; explain why you would like to have this behaviour? &nbsp;Maybe there
is<br>
&gt; an<br>
&gt; alternative way to model this.<br>
&gt; <br>
&gt; To change the value of a variable from inside the process (using an<br>
&gt; action), simply use kcontext.setVariable(name, value). &nbsp;We do
not<br>
&gt; recommend manually changing the value of a process variable from<br>
&gt; outside<br>
&gt; the engine. &nbsp;Again, could you explain why you would like to have<br>
&gt; this<br>
&gt; functionality?<br>
&gt; <br>
&gt; Kris<br>
&gt; <br>
&gt; Quoting Alan.Gairey@tessella.com:<br>
&gt; <br>
&gt; &gt; Can the constraint for an EventWait node in a flow be code-based<br>
&gt; &gt; (rather <br>
&gt; &gt; than rule-based)? The Eclipse plug-in (v 5.0.1) doesn't allow
this<br>
&gt; to<br>
&gt; &gt; be <br>
&gt; &gt; specified, unlike say for a Split node, although the relevant
XML<br>
&gt; can<br>
&gt; &gt; of <br>
&gt; &gt; course be edited.<br>
&gt; &gt; Trying to load such a process flow results in a<br>
&gt; NullPointerException,<br>
&gt; &gt; <br>
&gt; &gt; because the constraint is always interpreted as a rule.<br>
&gt; &gt; <br>
&gt; &gt; Ideally what I'd like to do is have an EventWait node where the<br>
&gt; &gt; constraint <br>
&gt; &gt; tests the value of a process variable. This then leads me to<br>
&gt; another<br>
&gt; &gt; <br>
&gt; &gt; question; is there a way of setting the value of a process<br>
&gt; variable<br>
&gt; &gt; via <br>
&gt; &gt; the Drools Flow API?<br>
&gt; &gt; <br>
&gt; &gt; Thanks in advance for any help,<br>
&gt; &gt; <br>
&gt; &gt; Alan<br>
&gt; &gt; Tessella plc<br>
&gt; &gt; 26 The Quadrant, Abingdon Science Park, Abingdon, Oxfordshire,<br>
&gt; OX14<br>
&gt; &gt; 3YS<br>
&gt; &gt; E: Alan.Gairey@tessella.com, T: +44 (0)1235 555511, F: +44 (0)1235<br>
&gt; &gt; 553301<br>
&gt; &gt; www.tessella.com &nbsp; &nbsp;Registered in England No. 1466429<br>
&gt; &gt; <br>
&gt; &gt; This message is commercial in confidence and may be privileged.
It<br>
&gt; is<br>
&gt; &gt; <br>
&gt; &gt; intended for the addressee(s) only. Access to this message by<br>
&gt; anyone<br>
&gt; &gt; else <br>
&gt; &gt; is unauthorized and strictly prohibited. If you have received
this<br>
&gt; &gt; message <br>
&gt; &gt; in error, please inform the sender immediately. Please note that<br>
&gt; &gt; messages <br>
&gt; &gt; sent or received by the Tessella e-mail system may be monitored<br>
&gt; and<br>
&gt; &gt; stored <br>
&gt; &gt; in an information retrieval system.<br>
&gt; &gt; <br>
&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>