<span><font><font size="2" color="#0000ff" face="Verdana">Binding a variable to a fact in a branch of an &#39;or&#39; (as you are doing with EtsExecutionOrderXref_core00) is not useful, since you cannot use this binding in the consequence. (The rule might just as well fire due to the 2nd term (the &quot;or not...&quot;) being true, and then the variable would not be bound, causing NPE.<br>
<br>If you do need this binding to access the fact in the consequence, you should splt the rule.<br><br>-W<br></font></font></span><br><div class="gmail_quote">2009/12/2 Shah, Malay <span dir="ltr">&lt;<a href="mailto:Malay.Shah@morganstanley.com">Malay.Shah@morganstanley.com</a>&gt;</span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">


<div>
<div>
<div dir="ltr" align="left"><span><font size="2" color="#0000ff" face="Verdana">Thanks Mark. I removed the binding and the rule is compiled 
now, but while firing the rule over set of objects, I get a Null pointer 
exception. </font></span></div>
<div dir="ltr" align="left"><span><font size="2" color="#0000ff" face="Verdana">Here is the updated Drool rule:</font></span></div>
<div dir="ltr" align="left"><span><font size="2" color="#0000ff" face="Verdana"></font></span> </div>
<div dir="ltr" align="left"><span><font size="2" color="#0000ff" face="Verdana"><div class="im">dialect &quot;mvel&quot;<br>rule &quot;Legacy ETSDB 
Rule&quot;<br>when<br>        
EtsExecutionOrderHist_core0:EtsExecutionOrderHist_core(customerOrFirm != 
&quot;0&quot;)<br>        
EtsExecutionOrderXref_core00:EtsExecutionOrderXref_core<br>        
(<br>            
entityOID == 
EtsExecutionOrderHist_core0.entityOID,<br>            
entityRID == 
EtsExecutionOrderHist_core0.entityRID,<br>            
entityVID == 
EtsExecutionOrderHist_core0.entityVID,<br>            
referenceID != &quot;2&quot; &amp;&amp; referenceIDType == 
&quot;orderSubCapacity&quot;<br>        
)<br>        
or<br>        
not(EtsExecutionOrderXref_core<br>                
(<br>                    
entityOID == 
EtsExecutionOrderHist_core0.entityOID,<br>                    
entityRID == 
EtsExecutionOrderHist_core0.entityRID,<br>                    
entityVID == 
EtsExecutionOrderHist_core0.entityVID,<br>                    
referenceIDType == 
&quot;orderSubCapacity&quot;<br>                
)<br>            
)<br>then<br></div>    System.out.println(&quot;Rule 
fired&quot;);<br>end</font></span></div>
<div dir="ltr" align="left"><span><font size="2" color="#0000ff" face="Verdana"></font></span> </div>
<div dir="ltr" align="left"><span><font size="2" color="#0000ff" face="Verdana">and here is the stack trace:</font></span></div>
<div dir="ltr" align="left"><span><font size="2" color="#0000ff" face="Verdana"></font></span> </div>
<div dir="ltr" align="left"><span><font size="2" color="#ff0000">Exception in thread &quot;main&quot; org.drools.runtime.rule.ConsequenceException: 
java.lang.NullPointerException<br> at 
org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:23)<br> at 
org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:943)<br> at 
org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:885)<br> at 
org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1086)<br> at 
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:660)<br> at 
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:637)<br> at 
org.drools.reteoo.ReteooStatelessSession.execute(ReteooStatelessSession.java:203)<br> at 
com.ms.ruleutils.RuleProcessor.process(RuleProcessor.java:142)<br> at 
com.ms.ruleutils.RuleProcessor.process(RuleProcessor.java:73)<br> at 
com.ms.ieddata.dataQuality.dqWithRR.DQCommandLineMain.performDQ(DQCommandLineMain.java:291)<br> at 
com.ms.ieddata.dataQuality.dqWithRR.DQCommandLineMain.runEngine(DQCommandLineMain.java:196)<br> at 
com.ms.ieddata.dataQuality.dqWithRR.DQCommandLineMain.main(DQCommandLineMain.java:170)<br>Caused 
by: java.lang.NullPointerException<br> at 
org.drools.base.mvel.DroolsMVELFactory.getTupleObjectFor(DroolsMVELFactory.java:182)<br> at 
org.drools.base.mvel.DroolsMVELFactory.setContext(DroolsMVELFactory.java:176)<br> at 
org.drools.base.mvel.MVELConsequence.evaluate(MVELConsequence.java:57)<br> at 
org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:934)<br> ... 
10 more</font></span></div>
<div><font size="2" color="#0000ff" face="Verdana"></font> </div>
<div><span><font size="2" color="#0000ff" face="Verdana">After debugging through, DroolMVELFactory class object is looking for 
Declaration definition for &quot;EtsExecutionOrderXref_core00&quot;, not finding it, and 
hence giving a null pointer exception. I am using Drools 5.0.1. Any idea about 
why this would happen? Does the rule seem right now?</font></span><span><font size="2" color="#0000ff" face="Verdana"></font></span></div>
<div><span><font size="2" color="#0000ff" face="Verdana">Thanks</font></span></div>
<div><span><font size="2" color="#0000ff" face="Verdana"></font></span> </div>
<div style="color: black; font-family: arial;"><span style="font-size: 10pt;">Malay Shah</span></div>
<div style="color: black; font-family: arial;"><span style="font-size: 10pt;"><br> </span></div>
<div>
<hr>
<font size="2" face="Tahoma"><b>From:</b> <a href="mailto:rules-users-bounces@lists.jboss.org" target="_blank">rules-users-bounces@lists.jboss.org</a> 
[mailto:<a href="mailto:rules-users-bounces@lists.jboss.org" target="_blank">rules-users-bounces@lists.jboss.org</a>] <b>On Behalf Of </b>Mark 
Proctor<br><b>Sent:</b> Tuesday, December 01, 2009 6:56 PM<br><b>To:</b> Rules 
Users List<br><b>Subject:</b> Re: [rules-users] Drool Rule Error with &quot;or not&quot; 
condition<br></font><br></div><div><div></div><div class="h5">
<div></div>You are binding the result of the &#39;or&#39; to <font face="Verdana"><font size="2"><font color="#0000ff">EtsExecutionOrderXref_core00 </font></font></font>as 
the second part is a &#39;not&#39; which returns nothing, how would it be bound 
to?<br><br>Shah, Malay wrote: 
<blockquote type="cite">
  
  <div>
  <div><span><font size="2" face="Verdana">Hi 
  All,</font></span></div>
  <div> </div>
  <div><span><font size="2" face="Verdana">I have the 
  following drool rule that has &quot;or not&quot; under Entity Block. Basically, the rule 
  tries to check if there either exists an entity object 
  EtsExecutionOrderXref_core00 with the given conditions, or the 
  entity does not exist at all with some other 
  conditions. </font></span></div>
  <div><span><font size="2"></font></span> </div>
  <div><span></span><font face="Verdana"><font size="2"><font color="#0000ff">dialect &quot;mvel&quot;<br>rule &quot;Legacy ETSDB 
  Rule&quot;<br>when<br>EtsExecutionOrderHist_core0:EtsExecutionOrderHist_core(customerOrFirm 
  != 
  &quot;0&quot;)<br>EtsExecutionOrderXref_core00:<br>(<br> EtsExecutionOrderXref_core<br> (<br>  entityOID 
  == EtsExecutionOrderHist_core0.entityOID , entityRID == 
  EtsExecutionOrderHist_core0.entityRID , entityVID == 
  EtsExecutionOrderHist_core0.entityVID , referenceID != &quot;2&quot; &amp;&amp; 
  referenceIDType == &quot;orderSubCapacity&quot;<br> )<br> or 
  not(EtsExecutionOrderXref_core<br> (<br>  entityOID == 
  EtsExecutionOrderHist_core0.entityOID , entityRID == 
  EtsExecutionOrderHist_core0.entityRID , entityVID == 
  EtsExecutionOrderHist_core0.entityVID , referenceIDType == 
  &quot;orderSubCapacity&quot;<br> ))<br>)<br></font>then<br>end</font></font></div>
  <div> </div>
  <div><font size="2" color="#0000ff" face="Verdana">But, while compiling the rule, I 
  am getting the following errors:</font></div>
  <div> </div>
  <div><font size="2" face="Verdana"><font size="2">org.drools.compiler.DroolsParserException: [ERR 101] Line 22:16 no 
  viable alternative at input </font><font size="2" color="#2a00ff"><font size="2" color="#2a00ff">&#39;entityOID&#39;</font></font><font size="2"> in rule &quot;Legacy 
  ETSDB Rule&quot; in pattern not, </font></font></div>
  <div>
  <p><font size="2" face="Verdana"><font size="2">org.drools.compiler.DroolsParserException: [ERR 102] Line 22:68 
  mismatched input </font><font size="2" color="#2a00ff"><font size="2" color="#2a00ff">&#39;,&#39;</font></font><font size="2"> expecting </font><font size="2" color="#2a00ff"><font size="2" color="#2a00ff">&#39;(&#39;</font></font><font size="2"> in rule 
  &quot;Legacy ETSDB Rule&quot; in pattern EtsExecutionOrderHist_core0.entityOID, 
  </font></font></p>
  <p><font size="2" face="Verdana"><font size="2">org.drools.compiler.DroolsParserException: [ERR 102] Line 22:122 
  mismatched input </font><font size="2" color="#2a00ff"><font size="2" color="#2a00ff">&#39;,&#39;</font></font><font size="2"> expecting </font><font size="2" color="#2a00ff"><font size="2" color="#2a00ff">&#39;(&#39;</font></font><font size="2"> in rule 
  &quot;Legacy ETSDB Rule&quot; in pattern EtsExecutionOrderHist_core0.entityOID in 
  pattern EtsExecutionOrderHist_core0.entityRID, </font></font></p>
  <p><font size="2" face="Verdana"><font size="2">org.drools.compiler.DroolsParserException: [ERR 102] Line 22:176 
  mismatched input </font><font size="2" color="#2a00ff"><font size="2" color="#2a00ff">&#39;,&#39;</font></font><font size="2"> expecting </font><font size="2" color="#2a00ff"><font size="2" color="#2a00ff">&#39;(&#39;</font></font><font size="2"> in rule 
  &quot;Legacy ETSDB Rule&quot; in pattern EtsExecutionOrderHist_core0.entityOID in 
  pattern EtsExecutionOrderHist_core0.entityRID in pattern 
  EtsExecutionOrderHist_core0.entityVID]</font></font></p></div>
  <div><font size="2" face="Verdana"><span>I think the rule 
  is correct, but am not able to figure out these compilation errors. Could 
  anybody please comment on why this would happen? </span></font></div>
  <div> </div>
  <div><span><font size="2" face="Verdana">Thanks</font></span></div>
  <div> </div>
  <div style="color: black; font-family: arial;"><span style="font-size: 10pt;">Malay Shah</span></div></div>
  <div>
  <hr>
  </div>
  <p style="margin: 0in 0in 0pt; text-indent: 0in;"><span style="font-size: 8pt; color: gray;"><font size="1" color="gray" face="Arial">NOTICE: 
  If received in error, please destroy, and notify sender. Sender does not 
  intend to waive confidentiality or privilege. Use of this email is prohibited 
  when received in error. We<span style="font-size: 7.5pt; color: gray;"> may 
  monitor and store emails to the extent permitted by applicable 
  law.</span></font></span></p><pre><hr size="4" width="90%">
_______________________________________________
rules-users mailing list
<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a>
  </pre></blockquote><br></div></div></div><div><div></div><div class="h5">
<div>
<hr>
</div>
<p style="margin: 0in 0in 0pt; text-indent: 0in;"><span style="font-size: 8pt; color: gray;"><font size="1" color="gray" face="Arial">NOTICE: If received in error, please destroy, and notify sender. Sender does not intend to waive confidentiality or privilege. Use of this email is prohibited when received in error. We<span style="font-size: 7.5pt; color: gray;"> may monitor and store emails to the extent permitted by applicable law.</span></font></span></p>

<div></div></div></div></div>
<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></blockquote></div><br>