<html><head><style type='text/css'>p { margin: 0; }</style></head><body><div style='font-family: Times New Roman; font-size: 12pt; color: #000000'>When using "or", only one pattern of the or expression will be bound.<br>So, at runtime, onlty one variable $p1 or $p2 exists, and the other is null so the NPE at runtime.<br><br>By the way, I can't see you are using a or here, as you test exactly the same things ...<br><br><hr id="zwchr"><div style="color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><b>De: </b>"Joana Lopes" &lt;joanpl@gmail.com&gt;<br><b>À: </b>rules-users@lists.jboss.org<br><b>Envoyé: </b>Vendredi 18 Mai 2012 13:14:19<br><b>Objet: </b>[rules-users] Exception on at org.drools.reteoo.LeftTuple.get(LeftTuple.java:300) drools 5.0.1<br><br>Hi There,<div>I'm new to drools and i'm having a problem with a rule which has an OR:</div><div><div>/* Rule 25_OFF -------------------------------------------------------------------------------- */</div><div><br>
</div><div>rule "25_OFF"</div><div>&nbsp; when</div><div>$p1:InferenceFactValue( param!=null, param.parameterName == "sonar_8_cm", $v1:param.valueFloat &gt;= 10 ) or&nbsp;</div><div>$p2:InferenceFactValue( param!=null, param.parameterName == "sonar_8_cm", $v2:param.valueFloat &gt;= 10 )</div>
<div>&nbsp; then</div><div>&nbsp; &nbsp; InferenceUtils.log( LogLevel.DEBUG, InferenceUtils.DROOLS_RULE, "Global Clock: " + InferenceDateUtils.dateString( globalClock, false ), true, false );</div><div>&nbsp; &nbsp; InferenceUtils.log( LogLevel.DEBUG, InferenceUtils.DROOLS_RULE, "\t\tRegra 25_OFF " + "25", true, false );</div>
<div>&nbsp; &nbsp; InferenceFactValue[] params = {$p1, $p2};</div><div>&nbsp; &nbsp; RuleFire.addEndAlarm( inferenceAgent, droolsEngine, "AlarmPackage", "25", "25", params, globalClock );</div><div>end</div><div>
<br></div><div>No errors in knowledge builder</div><div><br></div><div><br></div><div>What happens is:</div><div><div><br></div><div>org.drools.runtime.rule.ConsequenceException: java.lang.NullPointerException</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>at org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:23)</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:943)</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:885)</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>at org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1086)</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:660)</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:627)</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>at org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:183)</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>at pt.holos.dva.agents.inference.process.DroolsInferenceEngine.fireAllRules(DroolsInferenceEngine.java:644)</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>at pt.holos.dva.agents.inference.process.DroolsInferenceEngine.receiveDataFromBuffer(DroolsInferenceEngine.java:342)</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>at pt.holos.dva.agents.inference.process.BufferedDataReceiver.sendDataToDrools(BufferedDataReceiver.java:454)</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>at pt.holos.dva.agents.inference.process.BufferedDataReceiver.run(BufferedDataReceiver.java:68)</div>
<div>Caused by: java.lang.NullPointerException</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>at org.drools.reteoo.LeftTuple.get(LeftTuple.java:300)</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>at AlarmPackage.Rule_25_OFF_0ConsequenceInvoker.evaluate(Rule_25_OFF_0ConsequenceInvoker.java:15)</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:934)</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>... 9 more</div>
</div><div><br></div><div><br></div><div>I've tried to see the source code and the declaration in&nbsp;&nbsp;org.drools.reteoo.LeftTuple.get(LeftTuple.java:300) is null. Can you give me some pointers please?</div><div><br></div>
<div>Thank you,</div><div>Joana P Lopes</div><div><br></div>-- <br><br>LinkedIn -&nbsp;<span style="font-family:Arial,Helvetica,'Nimbus Sans L',sans-serif;font-size:13px;line-height:15px"><a href="http://pt.linkedin.com/in/joanpl" title="View public profile" name="SafeHtmlFilter_webProfileURL" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;border-left-width:0px;border-style:initial;border-color:initial;outline-width:initial;outline-style:none;outline-color:initial;font-weight:inherit;font-style:inherit;font-size:13px;font-family:inherit;vertical-align:baseline;text-decoration:underline;color:rgb(0,102,153)" target="_blank">http://pt.linkedin.com/in/joanpl</a></span><br>
My Bla Bla Bla: <a href="http://joanpl.blogspot.com" target="_blank">http://joanpl.blogspot.com</a><br>.......................................................<br>The intuitive mind is a sacred gift and the rational mind is a faithful servant. We have created a society that honors the servant and has forgotten the gift. Albert Einstein.<br>
"Doubt is not a pleasant condition, but certainty is absurd."<br>Voltaire<br><br><br>
</div>
<br>_______________________________________________<br>rules-users mailing list<br>rules-users@lists.jboss.org<br>https://lists.jboss.org/mailman/listinfo/rules-users<br></div><br></div></body></html>