<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML><head><META content="text/html; charset=us-ascii" http-equiv="Content-Type">

<META content="text/html; charset=us-ascii" http-equiv=Content-Type>
<META content="MSHTML 6.00.6000.16915" name=GENERATOR></head><BODY>
<DIV>
<DIV align=left dir=ltr><SPAN class=484345317-02122009><FONT color=#0000ff face=Verdana size=2>Mark,</FONT></SPAN></DIV>
<DIV align=left dir=ltr><SPAN class=484345317-02122009><FONT color=#0000ff face=Verdana size=2></FONT></SPAN>&nbsp;</DIV>
<DIV align=left dir=ltr><SPAN class=484345317-02122009><FONT color=#0000ff face=Verdana size=2>In this case, the object types that are bound don't have 
"not"/"or" conditions surrounding them (ExecutionOrderHist_core0 and 
ExecutionHist_core0). So, these objects would always be there when the rule is 
fired. Why would it still not identify and populate the variables of the 
objects, and instead try to cast one object to another?</FONT></SPAN></DIV>
<DIV><FONT color=#0000ff face=Verdana size=2></FONT><FONT color=#0000ff face=Verdana size=2></FONT>&nbsp;</DIV>
<DIV><SPAN class=484345317-02122009><FONT color=#0000ff face=Verdana size=2>Thanks</FONT></SPAN></DIV>
<DIV><SPAN class=484345317-02122009><FONT color=#0000ff face=Verdana size=2></FONT></SPAN>&nbsp;</DIV>
<DIV style="COLOR: black; FONT-FAMILY: arial"><SPAN style="FONT-SIZE: 10pt">Malay Shah<BR></SPAN></DIV>
<DIV><SPAN class=484345317-02122009><FONT color=#0000ff face=Verdana size=2>&nbsp;</FONT></SPAN></DIV>
<DIV><SPAN class=484345317-02122009>&nbsp;</SPAN></DIV>
<DIV>
<HR tabIndex=-1>
</DIV>
<DIV><FONT face=Tahoma size=2><B>From:</B> rules-users-bounces@lists.jboss.org 
[mailto:rules-users-bounces@lists.jboss.org] <B>On Behalf Of </B>Mark 
Proctor<BR><B>Sent:</B> Wednesday, December 02, 2009 12:44 PM<BR><B>To:</B> 
Rules Users List<BR><B>Subject:</B> Re: [rules-users] Drool Rule Error with "or 
not" condition<BR></FONT><BR></DIV>
<DIV></DIV>when using 'or' the bindings and the object types for those bindings 
must balance for each logical outcome.<BR><BR>Mark<BR>Shah, Malay wrote: 
<BLOCKQUOTE cite=mid:58A2A0069BCCBD4EA2F204631427BB9D01AFA4CF@NYWEXMBX2130.msad.ms.com type="cite">
  <META content="MSHTML 6.00.6000.16915" name=GENERATOR>
  <DIV>
  <DIV align=left dir=ltr><SPAN class=756320616-02122009><FONT color=#0000ff face=Verdana size=2>Thanks W. </FONT></SPAN></DIV>
  <DIV align=left dir=ltr><SPAN class=756320616-02122009></SPAN>&nbsp;</DIV>
  <DIV align=left dir=ltr><SPAN class=756320616-02122009><FONT color=#0000ff face=Verdana size=2>I removed the binding of EtsExecutionOrderXref_core00, 
  and it looked good. But I am getting ClassCastException when adding new facts 
  and conditions. I now have a new fact (EtsExecutionHist_core0) and an eval 
  statement to check if the rule has already been fired for a unique key that is 
  determined by variables in EtsExecutionHist_core0 fact. </FONT></SPAN></DIV>
  <DIV align=left dir=ltr><SPAN class=756320616-02122009></SPAN>&nbsp;</DIV>
  <DIV align=left dir=ltr><SPAN class=756320616-02122009><FONT color=#0000ff size=2>Exception in thread "main" org.drools.RuntimeDroolsException: 
  !(violations.containsKey("S-50_EtsExecutionHist_core" + "_entityOID_" + 
  EtsExecutionHist_core0_entityOID<BR>+ "_entityVID_" + 
  EtsExecutionHist_core0_entityVID<BR>)) : </FONT><STRONG><FONT color=#ff0000><FONT size=2>[Error: 
  com.ms.ieddata.etsdb.model.EtsExecutionOrderHist_core cannot be cast to 
  com.ms.ieddata.etsdb.model.EtsExecutionHist_core]</FONT><BR></FONT></STRONG></SPAN></DIV>
  <DIV align=left dir=ltr><SPAN class=756320616-02122009><FONT color=#0000ff face=Verdana size=2>When I don't have the eval statement, the rule works 
  perfectly well. Also, I checked that if I flip the order of defining facts in 
  the rule (i.e. having EtsExecutionHist_core0 fact before 
  EtsExecutionOrderHist_core0), the rule works fine. </FONT></SPAN></DIV>
  <DIV align=left dir=ltr><SPAN class=756320616-02122009></SPAN>&nbsp;</DIV>
  <DIV align=left dir=ltr><SPAN class=756320616-02122009><FONT color=#0000ff face=Verdana size=2>Below is the drool code and the 
error:</FONT></SPAN></DIV>
  <DIV align=left dir=ltr><SPAN class=756320616-02122009></SPAN>&nbsp;</DIV>
  <DIV align=left dir=ltr><SPAN class=756320616-02122009><FONT color=#008000 face=Verdana size=2><STRONG>Drool Rule:</STRONG></FONT></SPAN></DIV>
  <DIV align=left dir=ltr><SPAN class=756320616-02122009></SPAN>&nbsp;</DIV>
  <DIV align=left dir=ltr><SPAN class=756320616-02122009><FONT color=#0000ff size=2>package S_50 </FONT></SPAN></DIV>
  <DIV>&nbsp;</DIV>
  <DIV align=left dir=ltr><SPAN class=756320616-02122009><FONT color=#0000ff size=2>import com.ms.ieddata.dataQuality.violation.Violation;<BR>import 
  com.ms.ieddata.etsdb.model.EtsExecutionOrderHist_core;<BR>import 
  com.ms.ieddata.etsdb.model.EtsExecutionHist_core;<BR>import 
  com.ms.ieddata.etsdb.model.EtsExecutionOrderXref_core;</FONT></SPAN></DIV>
  <DIV><SPAN class=756320616-02122009><FONT color=#0000ff size=2>global 
  java.util.HashMap violations;</FONT></SPAN></DIV>
  <DIV><SPAN class=756320616-02122009><FONT color=#0000ff size=2>dialect 
  "mvel"<BR>rule "Legacy ETSDB 
  Rule"<BR>when<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  EtsExecutionOrderHist_core0:EtsExecutionOrderHist_core<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  (<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  customerOrFirm != "0"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  )<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  EtsExecutionHist_core0:EtsExecutionHist_core<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  (<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  parentOID == 
  EtsExecutionOrderHist_core0.entityOID,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  lastCapacity == 
  "1",<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  application != "MMETL",<BR><STRONG><FONT color=#ff0000>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  EtsExecutionHist_core0_entityOID:entityOID,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  EtsExecutionHist_core0_entityVID:entityVID</FONT></STRONG><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  )<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  EtsExecutionOrderXref_core<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  (<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  entityOID == 
  EtsExecutionOrderHist_core0.entityOID,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  entityRID == 
  EtsExecutionOrderHist_core0.entityRID,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  entityVID == 
  EtsExecutionOrderHist_core0.entityVID,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  referenceID != "2" &amp;&amp; referenceIDType == 
  "orderSubCapacity"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  )<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  or<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  not(EtsExecutionOrderXref_core<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  (<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  entityOID == 
  EtsExecutionOrderHist_core0.entityOID,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  entityRID == 
  EtsExecutionOrderHist_core0.entityRID,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  entityVID == 
  EtsExecutionOrderHist_core0.entityVID,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  referenceIDType == 
  "orderSubCapacity"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  )<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  )<BR><FONT color=#ff0000><STRONG>eval(!(violations.containsKey("S-50_EtsExecutionHist_core" 
  + "_entityOID_" + EtsExecutionHist_core0_entityOID + "_entityVID_" + 
  EtsExecutionHist_core0_entityVID)))</STRONG></FONT><BR>then<BR>&nbsp;&nbsp;&nbsp; 
  System.out.println("Rule Fired");<BR>end</FONT></SPAN></DIV>
  <DIV>&nbsp;</DIV>
  <DIV><SPAN class=756320616-02122009><FONT color=#008000 face=Verdana size=2><STRONG>Exception:</STRONG></FONT></SPAN></DIV>
  <DIV>&nbsp;</DIV>
  <DIV><FONT color=#0000ff size=2>Exception in thread "main" 
  org.drools.RuntimeDroolsException: 
  !(violations.containsKey("S-50_EtsExecutionHist_core" + "_entityOID_" + 
  EtsExecutionHist_core0_entityOID<BR>+ "_entityVID_" + 
  EtsExecutionHist_core0_entityVID<BR>)) : <FONT color=#ff0000><STRONG>[Error: 
  com.ms.ieddata.etsdb.model.EtsExecutionOrderHist_core cannot be cast to 
  com.ms.ieddata.etsdb.model.EtsExecutionHist_core]<BR></STRONG></FONT>[Near : 
  {... Unknown 
  ....}]<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  ^<BR>[Line: 1, Column: 0]<BR>&nbsp;at 
  org.drools.rule.EvalCondition.isAllowed(EvalCondition.java:122)<BR>&nbsp;at 
  org.drools.reteoo.EvalConditionNode.assertLeftTuple(EvalConditionNode.java:180)<BR>&nbsp;at 
  org.drools.reteoo.SingleLeftTupleSinkAdapter.doPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:117)<BR>&nbsp;at 
  org.drools.reteoo.SingleLeftTupleSinkAdapter.propagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:34)<BR>&nbsp;at 
  org.drools.reteoo.NotNode.assertLeftTuple(NotNode.java:123)<BR>&nbsp;at 
  org.drools.reteoo.CompositeLeftTupleSinkAdapter.doPropagateAssertLeftTuple(CompositeLeftTupleSinkAdapter.java:145)<BR>&nbsp;at 
  org.drools.reteoo.CompositeLeftTupleSinkAdapter.propagateAssertLeftTuple(CompositeLeftTupleSinkAdapter.java:39)<BR>&nbsp;at 
  org.drools.reteoo.JoinNode.assertLeftTuple(JoinNode.java:116)<BR>&nbsp;at 
  org.drools.reteoo.SingleLeftTupleSinkAdapter.doPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:117)<BR>&nbsp;at 
  org.drools.reteoo.SingleLeftTupleSinkAdapter.createAndPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:78)<BR>&nbsp;at 
  org.drools.reteoo.LIANodePropagation.doPropagation(LIANodePropagation.java:47)<BR>&nbsp;at 
  org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:649)<BR>&nbsp;at 
  org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:637)<BR>&nbsp;at 
  org.drools.reteoo.ReteooStatelessSession.execute(ReteooStatelessSession.java:203)<BR>&nbsp;at 
  com.ms.ruleutils.RuleProcessor.process(RuleProcessor.java:142)<BR>&nbsp;at 
  com.ms.ruleutils.RuleProcessor.process(RuleProcessor.java:73)<BR>&nbsp;at 
  com.ms.ieddata.dataQuality.dqWithRR.DQCommandLineMain.performDQ(DQCommandLineMain.java:291)<BR>&nbsp;at 
  com.ms.ieddata.dataQuality.dqWithRR.DQCommandLineMain.runEngine(DQCommandLineMain.java:196)<BR>&nbsp;at 
  com.ms.ieddata.dataQuality.dqWithRR.DQCommandLineMain.main(DQCommandLineMain.java:170)<BR>Caused 
  by: [Error: com.ms.ieddata.etsdb.model.EtsExecutionOrderHist_core cannot be 
  cast to com.ms.ieddata.etsdb.model.EtsExecutionHist_core]<BR>[Near : {... 
  Unknown 
  ....}]<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  ^<BR>[Line: 1, Column: 0]<BR>&nbsp;at 
  org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:388)<BR>&nbsp;at 
  org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeAccessor(ReflectiveAccessorOptimizer.java:138)<BR>&nbsp;at 
  org.mvel2.ast.ASTNode.getReducedValueAccelerated(ASTNode.java:133)<BR>&nbsp;at 
  org.mvel2.ast.BinaryOperation.getReducedValueAccelerated(BinaryOperation.java:102)<BR>&nbsp;at 
  org.mvel2.compiler.ExecutableAccessor.getValue(ExecutableAccessor.java:37)<BR>&nbsp;at 
  org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.getMethod(ReflectiveAccessorOptimizer.java:833)<BR>&nbsp;at 
  org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:315)<BR>&nbsp;at 
  org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeAccessor(ReflectiveAccessorOptimizer.java:138)<BR>&nbsp;at 
  org.mvel2.ast.ASTNode.getReducedValueAccelerated(ASTNode.java:133)<BR>&nbsp;at 
  org.mvel2.compiler.ExecutableAccessor.getValue(ExecutableAccessor.java:37)<BR>&nbsp;at 
  org.mvel2.ast.Substatement.getReducedValueAccelerated(Substatement.java:40)<BR>&nbsp;at 
  org.mvel2.compiler.ExecutableAccessor.getValue(ExecutableAccessor.java:37)<BR>&nbsp;at 
  org.mvel2.ast.Negation.getReducedValueAccelerated(Negation.java:44)<BR>&nbsp;at 
  org.mvel2.MVELRuntime.execute(MVELRuntime.java:85)<BR>&nbsp;at 
  org.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:104)<BR>&nbsp;at 
  org.mvel2.MVEL.executeExpression(MVEL.java:978)<BR>&nbsp;at 
  org.drools.base.mvel.MVELEvalExpression.evaluate(MVELEvalExpression.java:83)<BR>&nbsp;at 
  org.drools.rule.EvalCondition.isAllowed(EvalCondition.java:117)<BR>&nbsp;... 
  18 more<BR>Caused by: java.lang.ClassCastException: 
  com.ms.ieddata.etsdb.model.EtsExecutionOrderHist_core cannot be cast to 
  com.ms.ieddata.etsdb.model.EtsExecutionHist_core<BR>&nbsp;at 
  org.drools.base.com.ms.ieddata.etsdb.model.EtsExecutionHist_core32580467$getEntityVID.getValue(Unknown 
  Source)<BR>&nbsp;at 
  org.drools.base.ClassFieldReader.getValue(ClassFieldReader.java:91)<BR>&nbsp;at 
  org.drools.rule.Declaration.getValue(Declaration.java:244)<BR>&nbsp;at 
  org.drools.base.mvel.DroolsMVELPreviousDeclarationVariable.getValue(DroolsMVELPreviousDeclarationVariable.java:67)<BR>&nbsp;at 
  org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.getBeanProperty(ReflectiveAccessorOptimizer.java:446)<BR>&nbsp;at 
  org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:312)<BR>&nbsp;... 
  35 more</FONT></DIV>
  <DIV>&nbsp;</DIV>
  <DIV><SPAN class=756320616-02122009><FONT color=#0000ff face=Verdana size=2>Am 
  I missing something here? I think this is a perfectly valid rule, where eval 
  statement is needed to make sure we don't fire the rule multiple times. I 
  don't have the entire consequence section in the drool code above, but we 
  perform multiple actions if rules are fired. I am trying to get to the bottom 
  of this, because we generate these Drool Rule Code on the fly, and I can't 
  determine the order in which facts (and their variables) would be 
  defined.</FONT></SPAN></DIV>
  <DIV><SPAN class=756320616-02122009></SPAN>&nbsp;</DIV>
  <DIV><SPAN class=756320616-02122009><FONT color=#0000ff face=Verdana size=2>Any kind of help here would be much appreciated.</FONT></SPAN></DIV>
  <DIV><SPAN class=756320616-02122009></SPAN>&nbsp;</DIV>
  <DIV><SPAN class=756320616-02122009><FONT color=#0000ff face=Verdana size=2>Thanks</FONT></SPAN></DIV>
  <DIV>&nbsp;</DIV>
  <DIV style="COLOR: black; FONT-FAMILY: arial"><SPAN style="FONT-SIZE: 10pt">Malay Shah<BR></SPAN><SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 7.5pt"><BR></SPAN></DIV>
  <DIV>&nbsp;</DIV><BR>
  <DIV align=left class=OutlookMessageHeader dir=ltr lang=en-us>
  <HR tabIndex=-1>
  <FONT face=Tahoma size=2><B>From:</B> <A class=moz-txt-link-abbreviated href="mailto:rules-users-bounces@lists.jboss.org">rules-users-bounces@lists.jboss.org</A> 
  [<A class=moz-txt-link-freetext href="mailto:rules-users-bounces@lists.jboss.org">mailto:rules-users-bounces@lists.jboss.org</A>] 
  <B>On Behalf Of </B>Wolfgang Laun<BR><B>Sent:</B> Wednesday, December 02, 2009 
  1:47 AM<BR><B>To:</B> Rules Users List<BR><B>Subject:</B> Re: [rules-users] 
  Drool Rule Error with "or not" condition<BR></FONT><BR></DIV><SPAN><FONT size=+0><FONT color=#0000ff face=Verdana size=2>Binding a variable to a fact 
  in a branch of an 'or' (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 "or not...") 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" moz-do-not-send="true">Malay.Shah@morganstanley.com</A>&gt;</SPAN><BR>
  <BLOCKQUOTE class=gmail_quote style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">
    <DIV>
    <DIV>
    <DIV align=left dir=ltr><SPAN><FONT color=#0000ff face=Verdana size=2>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 align=left dir=ltr><SPAN><FONT color=#0000ff face=Verdana size=2>Here 
    is the updated Drool rule:</FONT></SPAN></DIV>
    <DIV align=left dir=ltr><SPAN></SPAN>&nbsp;</DIV>
    <DIV align=left dir=ltr><SPAN><FONT color=#0000ff face=Verdana size=2>
    <DIV class=im>dialect "mvel"<BR>rule "Legacy ETSDB 
    Rule"<BR>when<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
    EtsExecutionOrderHist_core0:EtsExecutionOrderHist_core(customerOrFirm != 
    "0")<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
    EtsExecutionOrderXref_core00:EtsExecutionOrderXref_core<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
    (<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
    entityOID == 
    EtsExecutionOrderHist_core0.entityOID,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
    entityRID == 
    EtsExecutionOrderHist_core0.entityRID,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
    entityVID == 
    EtsExecutionOrderHist_core0.entityVID,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
    referenceID != "2" &amp;&amp; referenceIDType == 
    "orderSubCapacity"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
    )<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
    or<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
    not(EtsExecutionOrderXref_core<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
    (<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
    entityOID == 
    EtsExecutionOrderHist_core0.entityOID,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
    entityRID == 
    EtsExecutionOrderHist_core0.entityRID,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
    entityVID == 
    EtsExecutionOrderHist_core0.entityVID,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
    referenceIDType == 
    "orderSubCapacity"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
    )<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
    )<BR>then<BR></DIV>&nbsp;&nbsp;&nbsp; System.out.println("Rule 
    fired");<BR>end</FONT></SPAN></DIV>
    <DIV align=left dir=ltr><SPAN></SPAN>&nbsp;</DIV>
    <DIV align=left dir=ltr><SPAN><FONT color=#0000ff face=Verdana size=2>and 
    here is the stack trace:</FONT></SPAN></DIV>
    <DIV align=left dir=ltr><SPAN></SPAN>&nbsp;</DIV>
    <DIV align=left dir=ltr><SPAN><FONT color=#ff0000 size=2>Exception in thread 
    "main" org.drools.runtime.rule.ConsequenceException: 
    java.lang.NullPointerException<BR>&nbsp;at 
    org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:23)<BR>&nbsp;at 
    org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:943)<BR>&nbsp;at 
    org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:885)<BR>&nbsp;at 
    org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1086)<BR>&nbsp;at 
    org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:660)<BR>&nbsp;at 
    org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:637)<BR>&nbsp;at 
    org.drools.reteoo.ReteooStatelessSession.execute(ReteooStatelessSession.java:203)<BR>&nbsp;at 
    com.ms.ruleutils.RuleProcessor.process(RuleProcessor.java:142)<BR>&nbsp;at 
    com.ms.ruleutils.RuleProcessor.process(RuleProcessor.java:73)<BR>&nbsp;at 
    com.ms.ieddata.dataQuality.dqWithRR.DQCommandLineMain.performDQ(DQCommandLineMain.java:291)<BR>&nbsp;at 
    com.ms.ieddata.dataQuality.dqWithRR.DQCommandLineMain.runEngine(DQCommandLineMain.java:196)<BR>&nbsp;at 
    com.ms.ieddata.dataQuality.dqWithRR.DQCommandLineMain.main(DQCommandLineMain.java:170)<BR>Caused 
    by: java.lang.NullPointerException<BR>&nbsp;at 
    org.drools.base.mvel.DroolsMVELFactory.getTupleObjectFor(DroolsMVELFactory.java:182)<BR>&nbsp;at 
    org.drools.base.mvel.DroolsMVELFactory.setContext(DroolsMVELFactory.java:176)<BR>&nbsp;at 
    org.drools.base.mvel.MVELConsequence.evaluate(MVELConsequence.java:57)<BR>&nbsp;at 
    org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:934)<BR>&nbsp;... 
    10 more</FONT></SPAN></DIV>
    <DIV>&nbsp;</DIV>
    <DIV><SPAN><FONT color=#0000ff face=Verdana size=2>After debugging through, 
    DroolMVELFactory class object is looking for Declaration definition for 
    "EtsExecutionOrderXref_core00", 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></SPAN></DIV>
    <DIV><SPAN><FONT color=#0000ff face=Verdana size=2>Thanks</FONT></SPAN></DIV>
    <DIV><SPAN></SPAN>&nbsp;</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>&nbsp;</SPAN></DIV>
    <DIV>
    <HR>
    <FONT face=Tahoma size=2><B>From:</B> <A href="mailto:rules-users-bounces@lists.jboss.org" moz-do-not-send="true" target=_blank>rules-users-bounces@lists.jboss.org</A> [mailto:<A href="mailto:rules-users-bounces@lists.jboss.org" moz-do-not-send="true" 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 "or not" condition<BR></FONT><BR></DIV>
    <DIV>
    <DIV class=h5>You are binding the result of the 'or' to <FONT face=Verdana><FONT size=2><FONT color=#0000ff>EtsExecutionOrderXref_core00 
    </FONT></FONT></FONT>as the second part is a 'not' which returns nothing, 
    how would it be bound to?<BR><BR>Shah, Malay wrote: 
    <BLOCKQUOTE type="cite">
      <DIV>
      <DIV><SPAN><FONT face=Verdana size=2>Hi All,</FONT></SPAN></DIV>
      <DIV>&nbsp;</DIV>
      <DIV><SPAN><FONT face=Verdana size=2>I have the following drool rule that 
      has "or not" under Entity Block. Basically, the rule tries to check 
      if&nbsp;there either exists an entity object EtsExecutionOrderXref_core00 
      with&nbsp;the&nbsp;given conditions, or the entity does not exist at all 
      with some other conditions.&nbsp;</FONT></SPAN></DIV>
      <DIV><SPAN></SPAN>&nbsp;</DIV>
      <DIV><SPAN></SPAN><FONT face=Verdana><FONT size=2><FONT color=#0000ff>dialect "mvel"<BR>rule "Legacy ETSDB 
      Rule"<BR>when<BR>EtsExecutionOrderHist_core0:EtsExecutionOrderHist_core(customerOrFirm 
      != 
      "0")<BR>EtsExecutionOrderXref_core00:<BR>(<BR>&nbsp;EtsExecutionOrderXref_core<BR>&nbsp;(<BR>&nbsp;&nbsp;entityOID 
      == EtsExecutionOrderHist_core0.entityOID , entityRID == 
      EtsExecutionOrderHist_core0.entityRID , entityVID == 
      EtsExecutionOrderHist_core0.entityVID , referenceID != "2" &amp;&amp; 
      referenceIDType == "orderSubCapacity"<BR>&nbsp;)<BR>&nbsp;or 
      not(EtsExecutionOrderXref_core<BR>&nbsp;(<BR>&nbsp;&nbsp;entityOID == 
      EtsExecutionOrderHist_core0.entityOID , entityRID == 
      EtsExecutionOrderHist_core0.entityRID , entityVID == 
      EtsExecutionOrderHist_core0.entityVID , referenceIDType == 
      "orderSubCapacity"<BR>&nbsp;))<BR>)<BR></FONT>then<BR>end</FONT></FONT></DIV>
      <DIV>&nbsp;</DIV>
      <DIV><FONT color=#0000ff face=Verdana size=2>But, while compiling the 
      rule, I am getting the following errors:</FONT></DIV>
      <DIV>&nbsp;</DIV>
      <DIV><FONT face=Verdana size=2><FONT size=2>org.drools.compiler.DroolsParserException: [ERR 101] Line 22:16 no 
      viable alternative at input </FONT><FONT color=#2a00ff size=2><FONT color=#2a00ff size=2>'entityOID'</FONT></FONT><FONT size=2> in rule 
      "Legacy ETSDB Rule" in pattern not, </FONT></FONT></DIV>
      <DIV>
      <P><FONT face=Verdana size=2><FONT size=2>org.drools.compiler.DroolsParserException: [ERR 102] Line 22:68 
      mismatched input </FONT><FONT color=#2a00ff size=2><FONT color=#2a00ff size=2>','</FONT></FONT><FONT size=2> expecting </FONT><FONT color=#2a00ff size=2><FONT color=#2a00ff size=2>'('</FONT></FONT><FONT size=2> in rule 
      "Legacy ETSDB Rule" in pattern EtsExecutionOrderHist_core0.entityOID, 
      </FONT></FONT></P>
      <P><FONT face=Verdana size=2><FONT size=2>org.drools.compiler.DroolsParserException: [ERR 102] Line 22:122 
      mismatched input </FONT><FONT color=#2a00ff size=2><FONT color=#2a00ff size=2>','</FONT></FONT><FONT size=2> expecting </FONT><FONT color=#2a00ff size=2><FONT color=#2a00ff size=2>'('</FONT></FONT><FONT size=2> in rule 
      "Legacy ETSDB Rule" in pattern EtsExecutionOrderHist_core0.entityOID in 
      pattern EtsExecutionOrderHist_core0.entityRID, </FONT></FONT></P>
      <P><FONT face=Verdana size=2><FONT size=2>org.drools.compiler.DroolsParserException: [ERR 102] Line 22:176 
      mismatched input </FONT><FONT color=#2a00ff size=2><FONT color=#2a00ff size=2>','</FONT></FONT><FONT size=2> expecting </FONT><FONT color=#2a00ff size=2><FONT color=#2a00ff size=2>'('</FONT></FONT><FONT size=2> in rule 
      "Legacy ETSDB Rule" in pattern EtsExecutionOrderHist_core0.entityOID in 
      pattern EtsExecutionOrderHist_core0.entityRID in pattern 
      EtsExecutionOrderHist_core0.entityVID]</FONT></FONT></P></DIV>
      <DIV><FONT face=Verdana size=2><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>&nbsp;</DIV>
      <DIV><SPAN><FONT face=Verdana size=2>Thanks</FONT></SPAN></DIV>
      <DIV>&nbsp;</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 color=gray face=Arial size=1>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.&nbsp;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" moz-do-not-send="true" target=_blank>rules-users@lists.jboss.org</A>
<A href="https://lists.jboss.org/mailman/listinfo/rules-users" moz-do-not-send="true" target=_blank>https://lists.jboss.org/mailman/listinfo/rules-users</A>
  </PRE></BLOCKQUOTE><BR></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 color=gray face=Arial size=1>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.&nbsp;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><BR>_______________________________________________<BR>rules-users 
    mailing list<BR><A href="mailto:rules-users@lists.jboss.org" moz-do-not-send="true">rules-users@lists.jboss.org</A><BR><A href="https://lists.jboss.org/mailman/listinfo/rules-users" moz-do-not-send="true" target=_blank>https://lists.jboss.org/mailman/listinfo/rules-users</A><BR><BR></BLOCKQUOTE></DIV><BR></DIV>
  <DIV>
  <HR>
  </DIV>
  <P class=BulletedList style="MARGIN: 0in 0in 0pt; TEXT-INDENT: 0in"><SPAN style="FONT-SIZE: 8pt; COLOR: gray"><FONT color=gray face=Arial size=1>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.&nbsp;We<SPAN style="FONT-SIZE: 7.5pt; COLOR: gray; FONT-FAMILY: 'Arial','sans-serif'"> may 
  monitor and store emails to the extent permitted by applicable 
  law.</SPAN></FONT></SPAN></P><PRE wrap><HR SIZE=4 width="90%">
_______________________________________________
rules-users mailing list
<A class=moz-txt-link-abbreviated href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</A>
<A class=moz-txt-link-freetext href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</A>
  </PRE></BLOCKQUOTE><BR></DIV>
<DIV>
<HR>
</DIV>
<P CLASS="BulletedList" STYLE="MARGIN: 0in 0in 0pt; TEXT-INDENT: 0in; mso-list: none; tab-stops: .5in"><SPAN STYLE="FONT-SIZE: 8pt; COLOR: gray; mso-bidi-font-family: Arial"><FONT COLOR="gray" FACE="Arial" SIZE="1">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.&nbsp;We<SPAN STYLE="FONT-SIZE: 7.5pt; COLOR: gray; FONT-FAMILY: 'Arial','sans-serif'; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-ansi-language: EN-GB; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"> may monitor and store emails to the extent permitted by applicable law.</SPAN></FONT></SPAN></P>
<DIV></DIV></BODY></HTML>