The NPE could be triggered by the update call, happens in another rule&#39;s LHS.<br><br>It&#39;s possible that the fact reference bound to $secondAlert is already gone by the time that NPE happens - I&#39;m not sure about that.<br>
<br>-W<br><br><div class="gmail_quote">On 17 November 2011 23:03, Robert Crawford <span dir="ltr">&lt;<a href="mailto:crawford@kloognome.com">crawford@kloognome.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I enhanced my ConsequenceExceptionHandler and have a little more detail on<br>
this. I have this rule:<br>
<br>
rule &quot;Duplicate Alerts&quot;<br>
when<br>
    $firstAlert : TemperatureAlert( this.saved, this.valid )<br>
    $secondAlert : TemperatureAlert (this.location == $firstAlert.location,<br>
this != $firstAlert, this.saved, this.valid )<br>
then<br>
    LOG.info(&quot;Removing duplicate alert for &quot; + $firstAlert.getLocation());<br>
    $secondAlert.setValid(false);<br>
    $secondAlert.setInvalidAt(new Date());<br>
    update($secondAlert);<br>
end<br>
<br>
The TemperatureAlert class is not defined as an event.<br>
<br>
I&#39;m getting this exception:<br>
<br>
15:56:34,145 ERROR [STDERR] CONSEQUENCE EXCEPTION<br>
15:56:34,145 ERROR [STDERR] Exception executing consequence for rule<br>
&quot;Duplicate Alerts&quot; in xxx.xxxxxxx.rules: java.lang.NullPointerException<br>
15:56:34,145 ERROR [STDERR] START FACT DUMP:<br>
15:56:34,145 ERROR [STDERR]<br>
$firstAlert:xxx.xxxxxxx.TemperatureAlert@1e3c1689<br>
15:56:34,145 ERROR [STDERR] $secondAlert:null<br>
15:56:34,145 ERROR [STDERR] END FACT DUMP<br>
15:56:34,145 ERROR [STDERR] Exception executing consequence for rule<br>
&quot;Duplicate Alerts&quot; in xxx.xxxxxxx.rules: java.lang.NullPointerException<br>
<br>
<br>
I don&#39;t see how this activation could have ever happened.<br>
<br>
If there never was an object that qualified, the activation would never have<br>
been scheduled.<br>
<br>
If there was one, but it was updated so it no longer matched or was<br>
retracted, then the activation would have been cancelled.<br>
<br>
Everything -- EVERYTHING -- for the session is done within a single thread:<br>
<br>
           Runnable r = new Runnable() {<br>
                public void run() {<br>
                    while (!shuttingDown) {<br>
                        try {<br>
                            session.fireUntilHalt();<br>
                            while (!commandList.isEmpty()) {<br>
                                commandList.take().execute();<br>
                            }<br>
                        } catch (Throwable t) {<br>
                            t.printStackTrace();<br>
                        }<br>
                    }<br>
                }<br>
            };<br>
<br>
The &quot;commandList&quot; is a BlockingQueue of objects that, when execute() is<br>
called, variously insert, retract, or update objects. All the data feeding<br>
into the session flows through that queue. The halt() method is called<br>
either when the queue gets too long and periodically if it&#39;s not empty.<br>
<br>
Any ideas?<br>
<font color="#888888"><br>
--<br>
View this message in context: <a href="http://drools.46999.n3.nabble.com/Rules-called-with-null-references-tp3477164p3517204.html" target="_blank">http://drools.46999.n3.nabble.com/Rules-called-with-null-references-tp3477164p3517204.html</a><br>

Sent from the Drools: User forum mailing list archive at Nabble.com.<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>
</font></blockquote></div><br>