[rules-users] Inserting multiple objects of the same class as facts

Devarakonda, Murty murty.devarakonda at teamaol.com
Fri Aug 5 14:33:32 EDT 2011


Hello,
I am facing a problem with the following code with Drools 5.0.1:

I insert multiple objects as facts into my stateful session here:

===============================================================
StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();

 /**  mapTypes here is an array of MapType objects **/
        for(int i=0;i<mapTypes.length;i++) {
            System.out.println("Inserting the fact type: " + mapTypes[i]);
            ksession.insert(mapTypes[i]);
        }

        ksession.insert(ldapLookupKey);
        ksession.insert(ldapResponseMap);

        ksession.fireAllRules();
        ksession.dispose();
===============================================================

And here is my drools file:

===============================================================

rule "LocalRecipient"
    when
        $myMapType : MapType( name  ==  "LocalRecipient" )
        $lookupKey : String()
        $ldapResponseMap : Map()
        eval( ((($ldapResponseMap.get("zimbraMailDeliveryAddress").equals($lookupKey)) ||
                ($ldapResponseMap.get("zimbraMailAlias").equals($lookupKey)) ||
                ($ldapResponseMap.get("zimbraMailCatchAllAddress").equals($lookupKey))) &&
                ($ldapResponseMap.get("zimbraMailStatus").equals("enabled"))) )
    then
        System.out.println("This LocalRecipient rule should work");
        $myMapType.setQueryFilterCheck(true);
end



rule "VirtualMailboxDomain"
    when
        $myMapType : MapType( name  ==  "VirtualMailboxDomain" )
        $lookupKey : String()
        $ldapResponseMap : Map()
        eval( (($ldapResponseMap.get("zimbraDomainName").equals($lookupKey)) &&
               ($ldapResponseMap.get("zimbraDomainType").equals("local")) &&
               ($ldapResponseMap.get("zimbraMailStatus").equals("enabled"))) )
    then
        System.out.println("This VirtualMailboxDomain rule should work");
        $myMapType.setQueryFilterCheck(true);
End

===============================================================


Now the problem I am facing is, as long as I defined only rule001 above, it works like a charm and the MapType.QueryFilterCheck flag gets set to TRUE.

As soon I put the rule002 above, I started getting a NullPointerException with the following lines in the stack trace.

===============================================================
Caused by: java.lang.NullPointerException
        at com.aol.postfixcache.Rule_LocalRecipient_Rule_0.eval0(Rule_LocalRecipient_Rule_0.java:8)
        at com.aol.postfixcache.Rule_LocalRecipient_Rule_0Eval0Invoker.evaluate(Rule_LocalRecipient_Rule_0Eval0Invoker.java:23)
        at org.drools.rule.EvalCondition.isAllowed(EvalCondition.java:117)
===============================================================


I tried different combinations along with an extensive search to see why I am getting this, but couldn't crack it.  Appreciate your help.

Regards,
Murty.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20110805/171036aa/attachment.html 


More information about the rules-users mailing list