[rules-users] NullPointerException with Wrapper objects

dhai sdhari at hotmail.com
Wed May 13 01:14:27 EDT 2009


I am facing problems which many have encountered in the past. I searched
forums but could not get precise answer. The problem is with null values in
Wrapper objects. See the following code:

rule "Null Check " salience 100
        when
                Salary ( ld : loanDeduction==null || < 0f ) // loanDeduction
is java.lang.Float
        then
                log("Load return is null"); //Global function
                ld = 0f;
end

rule "Nett Salary" salience 70
        when
                Salary ( nett != ( gross – loanDeduction – pf) )
        then
                log("Invalid nett salary amount");
end

You may have idea what I am trying to do. But I get NullPointerException in
“Nett Salary” rule when I fire the rules having fact with null in the
loanDeduction attribute. I believe my “Null Check” exception should execute
first and it does when I put negative value in loadDeduction. What is
solution in such a case? 
-- 
View this message in context: http://www.nabble.com/NullPointerException-with-Wrapper-objects-tp23515500p23515500.html
Sent from the drools - user mailing list archive at Nabble.com.





More information about the rules-users mailing list