|
Hi, all, I’m using Drools 3.0.4 drl to test some simple rules, the
drl I’m using is similar to below, Import Applicant; rule "test_applicant_rule" when $applicant:
Applicant ($age: age, $salary : salary ->(($salary>1000) && ($age>21)
&& ($salary > $age)) ) then System.out.println("approve
applicant"); end where “Applicant” is a class has int attributes “age”,
and “salary” public class Applicant { private
int age; private
int salary; … } The drl is deployed into Drools successfully, but when I
invoke the rule engine by asserting “applicant” objects into
working memory, Drools will throw runtime exceptions as below: org.drools.RuntimeDroolsException: java.lang.NullPointerException at
org.drools.rule.PredicateConstraint.isAllowed(PredicateConstraint.java:94) at
org.drools.common.BetaNodeBinder.isAllowed(BetaNodeBinder.java:63) at
org.drools.reteoo.LeftInputAdapterNode.assertObject(LeftInputAdapterNode.java:138) at
org.drools.reteoo.ObjectSource.propagateAssertObject(ObjectSource.java:119) at
org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:158) at org.drools.reteoo.Rete.assertObject(Rete.java:120) at
org.drools.reteoo.ReteooRuleBase.assertObject(ReteooRuleBase.java:180) at
org.drools.reteoo.ReteooWorkingMemory.doAssertObject(ReteooWorkingMemory.java:69) at
org.drools.common.AbstractWorkingMemory.assertObject(AbstractWorkingMemory.java:538) at
org.drools.common.AbstractWorkingMemory.assertObject(AbstractWorkingMemory.java:394) at
prototype.DRLTest.main(DRLTest.java:80) Caused by: java.lang.NullPointerException at
tmp.Rule_test_applicant_rule_0Predicate0Invoker.evaluate(Rule_test_applicant_rule_0Predicate0Invoker.java:13) at
org.drools.rule.PredicateConstraint.isAllowed(PredicateConstraint.java:88) After looking into it, I found it’s the predicate
constraint in the condition drl is causing problem, $applicant: Applicant ($age: age,
$salary : salary ->(($salary>1000) && ($age>21) && ($salary
> $age)) ) As shown above, in salary’s predicate
constraint, age declaration is used, Could anyone help to answer me, am I using the drl in
correct way? Or dose Drools support using multiple declarations in one
predicate constraint? Chen Yong Ming CrimsonLogic
Pte Ltd Makes better sense The
integrity and security of Internet communications and in particular this eMail
and any attachments cannot be guaranteed. The CrimsonLogic group accepts no
liability whatsoever in connection therewith. You are strongly advised to carry
out all necessary virus checks and that you open this eMail and any attachments
at your own risk. |
- [drools-dev] About multiple predicate constraints in drl Yong Ming, Chen
- Re: [drools-dev] About multiple predicate constraints... Steven Williams
- Re: [drools-dev] About multiple predicate constra... Michael Neale
- RE: [drools-dev] About multiple predicate constraints... Yong Ming, Chen
