<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 12 (filtered medium)">
<style>
<!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page Section1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.Section1
        {page:Section1;}
-->
</style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-GB" link="blue" vlink="purple">
<div class="Section1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D">In fact in your case you when condition doesn’t make any sense – B will never equal the empty string as B isn’t a string.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D">You probable want the following:<o:p></o:p></span></p>
<p class="MsoNormal">rule “foo”<o:p></o:p></p>
<p class="MsoNormal">when<br>
$a :A(Type == "Prod" , objectB == null)<br>
then<br>
B bobject = new B();<o:p></o:p></p>
<p class="MsoNormal"> bobject.setType(“Prod”);<o:p></o:p></p>
<p class="MsoNormal"> bobject.setId($a.getNumber().getId());<o:p></o:p></p>
<p class="MsoNormal"> modify($a) {<o:p></o:p></p>
<p class="MsoNormal"> setObjectB(bobject);<o:p></o:p></p>
<p class="MsoNormal"> };<o:p></o:p></p>
<p class="MsoNormal">end<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D">This rule only executes when objectB is null, this means you won’t get into the loop as once you have created objectB the rule won’t evaluate to true again.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D">Thomas</span>
<o:p></o:p></p>
<p class="MsoNormal"><br>
<br>
<span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p></o:p></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:10.0pt;font-family:
"Tahoma","sans-serif"">From:</span></b><span lang="EN-US" style="font-size:10.0pt;
font-family:"Tahoma","sans-serif""> rules-users-bounces@lists.jboss.org [mailto:rules-users-bounces@lists.jboss.org]
<b>On Behalf Of </b>Esteban Aliverti<br>
<b>Sent:</b> 03 June 2010 23:43<br>
<b>To:</b> Rules Users List<br>
<b>Subject:</b> Re: [rules-users] Object Referencing Error<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Yes, your rule entered in an infinite loop because when every time you insert/modify/retract a Fact, rules are reevaluated to check if the insertion/modification/retraction generates activations or not. In your case, your rule is being
reevaluated every time you update your $a object, the evaluation ends firing the rule, and this starts an endless loop. <o:p></o:p></p>
<div>
<p class="MsoNormal">If you only have this behavior with this rule, you can consider using the "no-loop" attribute. If your problem is multiple rules being re executed (and you don't wont that) you can use "lock-on-active" attribute. Try to read the documentation
about these attributes for further information. <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">It is very important for the people new in drools to understand the life cycle of a rule.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">Best, <o:p></o:p></p>
<div>
<p class="MsoNormal">On Thu, Jun 3, 2010 at 7:33 PM, Fnu Mahalakshmi <<a href="mailto:FMahalakshmi@nyx.com">FMahalakshmi@nyx.com</a>> wrote:<o:p></o:p></p>
<p class="MsoNormal">Hi,<br>
<br>
I tried what you said but program goes into an infinite loop.<br>
It does not break out of the when loop only.<br>
I did exactly as you mentioned.<br>
In the test information I put in a.type = "Prod"<br>
And a.bObject(new B());<br>
Any idea whats wrong??<br>
<br>
Thanks,<br>
M<br>
<br>
-----Original Message-----<br>
From: <a href="mailto:rules-users-bounces@lists.jboss.org">rules-users-bounces@lists.jboss.org</a> [mailto:<a href="mailto:rules-users-bounces@lists.jboss.org">rules-users-bounces@lists.jboss.org</a>] On Behalf Of
<a href="mailto:rules-users-request@lists.jboss.org">rules-users-request@lists.jboss.org</a><br>
Sent: Thursday, June 03, 2010 4:52 PM<br>
To: <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
Subject: rules-users Digest, Vol 43, Issue 15<br>
<br>
Send rules-users mailing list submissions to<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<br>
To subscribe or unsubscribe via the World Wide Web, visit<br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
or, via email, send a message with subject or body 'help' to<br>
<a href="mailto:rules-users-request@lists.jboss.org">rules-users-request@lists.jboss.org</a><br>
<br>
You can reach the person managing the list at<br>
<a href="mailto:rules-users-owner@lists.jboss.org">rules-users-owner@lists.jboss.org</a><br>
<br>
When replying, please edit your Subject line so it is more specific<br>
than "Re: Contents of rules-users digest..."<br>
<br>
<br>
Today's Topics:<br>
<br>
1. Re: Object Referencing error: (Esteban Aliverti)<br>
<br>
<br>
----------------------------------------------------------------------<br>
<br>
Message: 1<br>
Date: Thu, 3 Jun 2010 17:51:10 -0300<br>
From: Esteban Aliverti <<a href="mailto:esteban.aliverti@gmail.com">esteban.aliverti@gmail.com</a>><br>
Subject: Re: [rules-users] Object Referencing error:<br>
To: Rules Users List <<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>><br>
Message-ID:<br>
<<a href="mailto:AANLkTimeZIJ5VfMTBESLFJIWoc_4MEZSXbKMIXAvJRiC@mail.gmail.com">AANLkTimeZIJ5VfMTBESLFJIWoc_4MEZSXbKMIXAvJRiC@mail.gmail.com</a>><br>
Content-Type: text/plain; charset="iso-8859-1"<br>
<br>
You can't modify bobject, becuase it doesn't exist inside the session. You<br>
just created it a few lines above. Maybe you need an insert() or maybe you<br>
need the bobject reference from the LHS. Something like this:<br>
<br>
*rule* "prod"<br>
<br>
<br>
<br>
*when*<br>
<br>
$a :A(Type == "Prod" , objectB != "")<br>
<br>
*then*<br>
<br>
B bobject = *new* B();<br>
<br>
$a.getObjectB().setType( "Prod" );<br>
<br>
$a.getObjectB().setId($a.getNumber().getId());<br>
<br>
*update*($a);<br>
<br>
* end*<br>
<br>
Note that you need to update $a and not B, because A is the inserted Fact in<br>
your session.<br>
<br>
Best,<br>
<br>
<br>
2010/6/3 Fnu Mahalakshmi <<a href="mailto:FMahalakshmi@nyx.com">FMahalakshmi@nyx.com</a>><br>
<br>
> Hi,<br>
><br>
><br>
><br>
> I am getting the following error when I try to do complex object<br>
> referencing in drools:<br>
><br>
> My class:<br>
><br>
> A{<br>
><br>
> String Type;<br>
><br>
> B objectb;<br>
><br>
> //getters and setters for above<br>
><br>
> }<br>
><br>
><br>
><br>
> My rules:<br>
><br>
><br>
><br>
> *rule* "prod"<br>
><br>
><br>
><br>
> *when*<br>
><br>
> $a :A(Type == "Prod" , objectB != "")<br>
><br>
> *then*<br>
><br>
> B bobject = *new* B();<br>
><br>
> bobject.setType( "Prod" );<br>
><br>
> bobject.setId($a.getNumber().getId());<br>
><br>
> *update*(bobject);<br>
><br>
><br>
><br>
> *end*<br>
><br>
> * *<br>
><br>
> *I want to basically output a file which has updated values of B (type,<br>
> Id)<br>
><br>
> *<br>
><br>
> * *<br>
><br>
> *Error:*<br>
><br>
> *org.drools.spi.ConsequenceException*: *org.drools.FactException*: Update<br>
> error: handle not found for object: com.org.Ip@f42ad0. Is it in the<br>
> working memory?<br>
><br>
> at<br>
> org.drools.base.DefaultConsequenceExceptionHandler.handleException(*<br>
> DefaultConsequenceExceptionHandler.java:13*)<br>
><br>
> at org.drools.common.DefaultAgenda.fireActivation(*<br>
> DefaultAgenda.java:558*)<br>
><br>
> at org.drools.common.DefaultAgenda.fireNextItem(*<br>
> DefaultAgenda.java:518*)<br>
><br>
> at org.drools.common.AbstractWorkingMemory.fireAllRules(*<br>
> AbstractWorkingMemory.java:475*)<br>
><br>
> at org.drools.common.AbstractWorkingMemory.fireAllRules(*<br>
> AbstractWorkingMemory.java:439*)<br>
><br>
> at com.org.DroolsTest.main(*DroolsTest.java:30*)<br>
><br>
> Caused by: *org.drools.FactException*: Update error: handle not found for<br>
> object: com.org.Ip@f42ad0. Is it in the working memory?<br>
><br>
> at org.drools.base.DefaultKnowledgeHelper.update(*<br>
> DefaultKnowledgeHelper.java:100*)<br>
><br>
> at com.org.Rule_Prod_Ip_0.consequence(*Rule_Prod_Ip_0.java:10*)<br>
><br>
> at com.org.Rule_Prod_Ip_0ConsequenceInvoker.evaluate(*<br>
> Rule_Prod_Ip_0ConsequenceInvoker.java:22*)<br>
><br>
> at org.drools.common.DefaultAgenda.fireActivation(*<br>
> DefaultAgenda.java:554*)<br>
><br>
> ... 4 more<br>
><br>
><br>
><br>
> Please help! I am very new to drools! Not able to figure out why this<br>
> error:<br>
><br>
><br>
><br>
> I am using eclipse and working on Windows machine. Error above was<br>
> generated on eclipse console.<br>
><br>
><br>
><br>
> Thank you.<br>
><br>
><br>
><br>
> M<br>
><br>
> ------------------------------<br>
><br>
> *Please consider the environment before printing this email.*<br>
><br>
> *Visit our website at <a href="http://www.nyse.com" target="_blank">http://www.nyse.com</a><br>
> *****************************************************************************<br>
><br>
> Note: The information contained in this message and any attachment to it is<br>
> privileged, confidential and protected from disclosure. If the reader of<br>
> this message is not the intended recipient, or an employee or agent<br>
> responsible for delivering this message to the intended recipient, you are<br>
> hereby notified that any dissemination, distribution or copying of this<br>
> communication is strictly prohibited. If you have received this<br>
> communication in error, please notify the sender immediately by replying to<br>
> the message, and please delete it from your system. Thank you. NYSE<br>
> Euronext. *<br>
><br>
><br>
> _______________________________________________<br>
> rules-users mailing list<br>
> <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
> <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">
https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
><br>
><br>
<br>
<br>
--<br>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br>
<br>
Esteban Aliverti<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <a href="http://lists.jboss.org/pipermail/rules-users/attachments/20100603/f0f29ddf/attachment.html" target="_blank">
http://lists.jboss.org/pipermail/rules-users/attachments/20100603/f0f29ddf/attachment.html</a><br>
<br>
------------------------------<br>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br>
<br>
End of rules-users Digest, Vol 43, Issue 15<br>
*******************************************<br>
Please consider the environment before printing this email.<br>
<br>
Visit our website at <a href="http://www.nyse.com" target="_blank">http://www.nyse.com</a><br>
<br>
****************************************************<br>
<br>
Note: The information contained in this message and any attachment to it is privileged, confidential and protected from disclosure. If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message
to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify the sender immediately by replying to the message,
and please delete it from your system. Thank you. NYSE Euronext.<br>
<br>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><o:p></o:p></p>
</div>
<p class="MsoNormal"><br>
<br clear="all">
<br>
-- <br>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br>
<br>
Esteban Aliverti<o:p></o:p></p>
</div>
</div>
</div>
<br>
<hr>
<font face="Arial" color="Gray" size="1"><br>
**************************************************************************************<br>
This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmaster@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data
may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary.<br>
<br>
NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00<br>
**************************************************************************************<br>
</font>
</body>
</html>