[rules-users] Eval0Invoker : java.lang.NullPointerException
Michael Anstis
michael.anstis at gmail.com
Thu Dec 15 11:13:45 EST 2011
Yikes!
This I had not even noticed.
Customer and ServiceContext should both be inserted as Facts.
Some rules might need to be re-written:-
rule "Customer null check rule"
no-loop true
salience 1000
when
not ( Customer() )
then
throw new MissingEntryFault("Customer is required");
end
rule "Service Context null check rule"
no-loop true
salience 1000
when
not ( ServiceContext() )
then
throw new MissingEntryFault("ServiceContext is required");
end
You must be inserting some (at least one) Customers in working memory
otherwise rules like this won't match anything:-
rule "PAN Device null or empty rule"
no-loop true
salience 300
when
$customer : Customer()
$esi : ElectricServiceInterface() from
$customer.getElectricServiceInterfaces()
eval( $esi.getPANdevices() == null ||
$esi.getPANdevices().size()<=0 )
then
throw new MissingEntryFault("PAN Device list cannot be null
or empty");
end
Which itself could be re-written removing the eval (I don't think you'll
get an NPE in the last "from"):-
rule "PAN Device null or empty rule"
no-loop true
salience 300
when
$customer : Customer()
$esi : ElectricServiceInterface() from
$customer.getElectricServiceInterfaces()
not ( PANDevice() from $esi.getPANdevices() )
then
throw new MissingEntryFault("PAN Device list cannot be null
or empty");
end
On 15 December 2011 16:03, Venkat <ven12344 at yahoo.com> wrote:
> Hi Manstis, I see what you are saying, and yes I not doing any update in my
> facts. If you see the rule file, there is global variable which defines the
> Customer and ServiceContext and also I am declaring the Customer object
> again in each rule.
>
> This is because I could not get those global variables access in other
> rules, can you tell me how to get those variables in other rules also.
>
> Thanks,
> Venkat.
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Eval0Invoker-java-lang-NullPointerException-tp3586222p3589057.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> 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/20111215/1388021a/attachment.html
More information about the rules-users
mailing list