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
Software Engineer, Technology Development
DID: 65 – 6887 7500
Fax: 65 – 6778 5277
CrimsonLogic Pte Ltd
(Regn No: 198800784N)
31 Science Park Road, The Crimson, Singapore 117611
Main Line: +65 6887 7888 Fax: +65 6778 5277
Visit us at www.crimsonlogic.com
Makes better sense
========================================================
NOTICE
This eMail and any attachments are intended solely for the named addressee(s) only. It contains confidential and/or privileged information which should not be copied or disclosed without the consent of the CrimsonLogic group. If you are not the intended recipient or if you have received this eMail in error, you must not copy, distribute, disclose or take any action in reliance on it (or any part of its contents). In such case, you should inform the CrimsonLogic group immediately by eMail or telephone +65 68877888 (reverse charges if necessary) and delete this eMail and any attachments from your system.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.
--
Steven Williams
Supervising Consultant
Object Consulting
Office: 8615 4500 Mob: 0439 898 668 Fax: 8615 4501
[EMAIL PROTECTED]
www.objectconsulting.com.au
consulting | development | training | support
our experience makes the difference
