Try adding another condition that checks policy.params != null in your customer condition of rule 2<br><br><div class="gmail_quote">On Sat, Dec 5, 2009 at 7:25 AM, Torfox <span dir="ltr"><<a href="mailto:bartosz.jankiewicz@gmail.com">bartosz.jankiewicz@gmail.com</a>></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;"><br>
Hi,<br>
<br>
I couldn't find an solution to a problem I'm struggling with for many hours.<br>
<br>
Generally I'm trying to implement sequential mode rules. I have applied<br>
salience parameters to order the rules, but the engine is not executing<br>
these rules in that order.<br>
<br>
I use drools 5.0.1 in sequential mode, stateless session.<br>
<br>
As far as I understand the documentation, in this mode the rules should be<br>
fired in accordance to the salience attribute.<br>
<br>
RuleBaseConfiguration conf = new RuleBaseConfiguration();<br>
conf.setSequential( true);<br>
KnowledgeBase knowledgeBase = KnowledgeBaseFactory.newKnowledgeBase(<br>
conf);<br>
session = knowledgeBase.newStatelessKnowledgeSession();<br>
...<br>
<br>
The following code snapshot proves that the execution order totally ignores<br>
salience - "rule2" is fired prior to the "rule1" causing<br>
NullPointerException since the Params is initiated in "rule1".<br>
<br>
package com.kaguar.pzu;<br>
<br>
import java.util.*;<br>
import com.kaguar.entities.*;<br>
<br>
global java.util.Set output;<br>
<br>
declare Params<br>
version : String<br>
modelGroup : Integer<br>
region : Integer<br>
end<br>
<br>
rule "rule1"<br>
salience 1000<br>
when<br>
$c: Customer()<br>
then<br>
Params p = new Params();<br>
p.setVersion( "1.0");<br>
insert( p);<br>
output.add( p);<br>
$c.getPolicy().setParams( p);<br>
System.out.println( "Initiation complete");<br>
end<br>
<br>
<br>
rule "rule2"<br>
salience 0<br>
when<br>
exists Params()<br>
$c: Customer( vehicle.age == 2, policy.params.modelGroup ==<br>
1, policy.params.region == 1)<br>
then<br>
System.out.println( "test");<br>
end<br>
<br>
Please help!!!<br>
<font color="#888888"><br>
--<br>
View this message in context: <a href="http://n3.nabble.com/Sequential-mode-help-tp68511p68511.html" target="_blank">http://n3.nabble.com/Sequential-mode-help-tp68511p68511.html</a><br>
Sent from the Drools - User 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>