[rules-users] NullPointerException with Wrapper objects

Wolfgang Laun wolfgang.laun at gmail.com
Wed May 13 08:00:57 EDT 2009


2009/5/13 Shabbir Dhari <sdhari at hotmail.com>

>  Thanks for all you efforts  :) but what is the difference between calling
> function from every rule or putting null check.
>

It's much easier to add.



> I give up. I am looking for other rule engines.
>

As they must apparently (due to JavaBeans) be Java-based, I'd be very much
surprised if you'll find what you are looking for.

-W



>
>
> ------------------------------
> Date: Wed, 13 May 2009 12:19:08 +0200
>
> Subject: Re: [rules-users] NullPointerException with Wrapper objects
> From: wolfgang.laun at gmail.com
> To: rules-users at lists.jboss.org
>
> Well, I hope you get paid for all the extra work ;-)
>
> Define, in your .drl file,
>
> function float safe( Float v ){
>       return v == null ? 0 : v;
> }
>
> and wrap all references to the "dangerous" field(s) in your LHS pattern
> expressions with this call, except, of course, in the rule where you fix and
> log the field.
>
> -W
>
>
>
> 2009/5/13 Shabbir Dhari <sdhari at hotmail.com>
>
>  Well I cant explain you all the issues and requirements here. Simply we
> dont have provision to do so. We have to check the null in the rules and log
> the message plus other evaluation and arithmetic.
>
> ------------------------------
> Date: Wed, 13 May 2009 10:36:59 +0200
>
> Subject: Re: [rules-users] NullPointerException with Wrapper objects
> From: wolfgang.laun at gmail.com
> To: rules-users at lists.jboss.org
>
> But you do control the insertion of your facts. Rather than cluttering
> rules with conditions dealing with irregular values, preprocess the object.
> And you should be able to log from there, just as well.
> -W
>
> 2009/5/13 Shabbir Dhari <sdhari at hotmail.com>
>
> I can not initialize property as need to log the message. The bean comes
> from outside our application scope. We do not have control to make them
> menodatory. And we need to log the message. You mean there is no solution of
> this problem? And remember my second rule does not compare propery but
> it performs some calculations.
>
> ------------------------------
> Date: Wed, 13 May 2009 09:01:05 +0200
> Subject: Re: [rules-users] NullPointerException with Wrapper objects
> From: wolfgang.laun at gmail.com
> To: rules-users at lists.jboss.org
>
> What about setting the field to 0 in the constructor of Salary?
> Or using float (not java.lang.Float)?
> -W
>
> 2009/5/13 Shabbir Dhari <sdhari at hotmail.com>
>
> I know this work around. But I have more than 50 rules using that attribute
> and it looks very ugly to put null on every rule and its not single
> attribute. There are more than 30 attributes in the bean and using them in
> LHS. Any other sophisticated way?
>
> > Date: Tue, 12 May 2009 23:15:54 -0700
> > From: greg_barton at yahoo.com
> > Subject: Re: [rules-users] NullPointerException with Wrapper objects
> > To: rules-users at lists.jboss.org
> >
> >
> > All conditions of all applicable rules are evaluated when you insert an
> object into working memory. This decides which rule actions can go on the
> agenda. Only when a rule action is on the agenda is the salience used to
> determine the order of action firing. So doing the null check in the way
> you're doing it will not work.
> >
> > You must put the null check in the same rule, before the potentially null
> property is used.
> >
> > rule "Nett Salary" salience 70
> > when
> > Salary ( loanDeduction != null, nett != ( gross – loanDeduction – pf) )
> > then
> > log("Invalid nett salary amount");
> > end
> >
>
>
> ------------------------------
> Check out the new Windows Live Messenger Looking for a fresh way to share
> your photos? <http://windowslive.ninemsn.com.au/article.aspx?id=792335>
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
>
> ------------------------------
> Click Here View photos of singles in your area<http://a.ninemsn.com.au/b.aspx?URL=http://dating.ninemsn.com.au/search/search.aspx?exec%3Dgo%26tp%3Dq%26gc%3D2%26tr%3D1%26lage%3D18%26uage%3D55%26cl%3D14%26sl%3D0%26dist%3D50%26po%3D1%26do%3D2%26trackingid%3D1046138%26r2s%3D1&_t=773166090&_r=Hotmail_Endtext&_m=EXT>
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
>
> ------------------------------
> Find out how with Windows Live! Want to stay on top of your life online?<http://windowslive.ninemsn.com.au/>
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
>
> ------------------------------
> Find out how with Windows Live! Want to stay on top of your life online?<http://windowslive.ninemsn.com.au/>
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20090513/8e331a7b/attachment.html 


More information about the rules-users mailing list