The following DRL produces a Null Pointer Exception when the "enabled"
attribute is set to false on "test rule 2". Any ideas why? Changing this
value to true or commenting out the rule causes things to succeed.
Environment: Java 7 and Drools 5.4
package tests
import org.apache.log4j.Logger;
import java.util.List;
global Logger log
declare Data
name : String
end
rule "insert Data"
when
then
insert(new Data("test"));
end
rule "test rule 2"
enabled false
when
d : List() from collect (Data( name == "test") )
then
log.info(String.format("%s hit on %s", kcontext.getRule().getName(), d));
end
Exception executing consequence for rule "insert Data" in tests:
java.lang.NullPointerException
at
org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1283)
at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1209)
at org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1442)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:710)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:674)
at
org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:230)
at
org.drools.impl.StatelessKnowledgeSessionImpl.execute(StatelessKnowledgeSessionImpl.java:278)
at tests.DroolsTest.testStateless(DroolsTest.java:98)
at tests.DroolsTest.runTest(DroolsTest.java:60)
at tests.DroolsTest.main(DroolsTest.java:45)
Caused by: java.lang.NullPointerException
at org.drools.common.DefaultAgenda.createActivation(DefaultAgenda.java:569)
at
org.drools.reteoo.RuleTerminalNode.modifyLeftTuple(RuleTerminalNode.java:297)
at
org.drools.reteoo.SingleLeftTupleSinkAdapter.propagateModifyChildLeftTuple(SingleLeftTupleSinkAdapter.java:259)
at
org.drools.reteoo.AccumulateNode.evaluateResultConstraints(AccumulateNode.java:676)
at
org.drools.reteoo.ReteooWorkingMemory$EvaluateResultConstraints.execute(ReteooWorkingMemory.java:591)
at
org.drools.common.PropagationContextImpl.evaluateActionQueue(PropagationContextImpl.java:345)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:342)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:298)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:888)
at
org.drools.base.DefaultKnowledgeHelper.insert(DefaultKnowledgeHelper.java:187)
at
org.drools.base.DefaultKnowledgeHelper.insert(DefaultKnowledgeHelper.java:181)
at
tests.Rule_insert_Data_2eb7a40b15e640d6bc777e1075d1218b.defaultConsequence(Rule_insert_Data_2eb7a40b15e640d6bc777e1075d1218b.java:7)
at
tests.Rule_insert_Data_2eb7a40b15e640d6bc777e1075d1218bDefaultConsequenceInvokerGenerated.evaluate(Unknown
Source)
at
tests.Rule_insert_Data_2eb7a40b15e640d6bc777e1075d1218bDefaultConsequenceInvoker.evaluate(Unknown
Source)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1273)
--
View this message in context:
http://drools.46999.n3.nabble.com/Bug-in-enabled-rule-attribute-tp4019049...
Sent from the Drools: User forum mailing list archive at
Nabble.com.