Ok, JIRA-749 created (assigned to default; Mark) Happy (bug) hunting.
-----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Edson Tirelli Sent: 23 March 2007 12:35 To: Rules Users List Subject: Re: [rules-users] Null Pointer Exceptionin "org.drools.reteoo.RuleTerminalNode.retractTuple" Michael, Yes, this is certainly a bug. May I ask you please to open a JIRA for that and attach your sample code? A comment about "no-loop": it only prevents the rule activating itself... it does not prevent the rule from activating other rules that already fired. You must add an explicit constraint to avoid the activation of the rules you don't want to activate when modifying objects that are part of the matching pattern. Thank you in advance. Edson Anstis, Michael (M.) wrote: > Hi - me again :-( > > Unfortunately I receive a NPE (3.1-M1) as follows (a complete JAR > illustrating the problem is available):- > > **Java > > Man man=*new* Man(); > Machine machine=*new* Machine(); > Process p =* new* Process(); > wm.assertObject(man); > wm.assertObject(machine); > wm.assertObject(p); > > **Rules > > *package* drools.debug > > *rule* "Rule-1" > *no-loop** true* > *when* > $p : Process() > *then* > System.out.println("DEBUG [Rule-1]---> Add ProcessAlternative > to Process"); > ProcessAlternative pa =* new* ProcessAlternative(); > $p.addProcessAlternative(pa); > * assert*(pa); > * modify*($p); > *end* > > *rule* "Rule-2" > *no-loop** true* > *when* > $m : Machine() > *then* > System.out.println("DEBUG [Rule-2]---> Add Machine to > MachineEntry"); > MachineEntry me =* new* MachineEntry(); > me.setMachine($m); > * assert*(me); > *end* > > *rule* "Rule-3" > *no-loop** true* > *when* > $me : MachineEntry() > $pa : ProcessAlternative() > *then* > System.out.println("DEBUG [Rule-3]---> Add MachineEntry to > ProcessAlternative"); > $pa.addMachineEntry($me); > * modify*($pa); > *end* > > //rule "Rule-4 (Null Pointer Exception)" > //no-loop true > //when > // $h : Man ( ) > // $m : Machine ( ) > // $mte : MachineEntry ( machine == $m ) > //then > // System.out.println("DEBUG [Rule 4]---> Assigned resource"); > // $m.setManualResource($h); > // modify($m); > //end > > **Output > > DEBUG [Rule-1]---> Add ProcessAlternative to Process > DEBUG [Rule-2]---> Add Machine to MachineEntry > DEBUG [Rule-3]---> Add MachineEntry to ProcessAlternative > > This is what I'd expect. If however rule "Rule-4" is uncommented the > output is:- > > DEBUG [Rule-1]---> Add ProcessAlternative to Process > DEBUG [Rule-2]---> Add Machine to MachineEntry > DEBUG [Rule-3]---> Add MachineEntry to ProcessAlternative > DEBUG [Rule 4]---> Assigned resource > DEBUG [Rule-2]---> Add Machine to MachineEntry <-- Why > activated? no-loop is true > DEBUG [Rule 4]---> Assigned resource <-- Presumably > activated as a consequence of above > > And I receive a NPE with the following stack trace:- > > _java.lang.NullPointerException_ > at > org.drools.reteoo.RuleTerminalNode.retractTuple(_RuleTerminalNode.java:2 67_) > > at > org.drools.reteoo.SingleTupleSinkAdapter.propagateRetractTuple(_SingleTu pleSinkAdapter.java:38_) > > at org.drools.reteoo.JoinNode.retractTuple(_JoinNode.java:217_) > at > org.drools.reteoo.SingleTupleSinkAdapter.propagateRetractTuple(_SingleTu pleSinkAdapter.java:38_) > > at org.drools.reteoo.JoinNode.retractObject(_JoinNode.java:183_) > at > org.drools.reteoo.CompositeObjectSinkAdapter.propagateRetractObject(_Com positeObjectSinkAdapter.java:369_) > > at > org.drools.reteoo.ObjectTypeNode.retractObject(_ObjectTypeNode.java:189_ ) > at org.drools.reteoo.Rete.retractObject(_Rete.java:171_) > at > org.drools.reteoo.ReteooRuleBase.retractObject(_ReteooRuleBase.java:215_ ) > at > org.drools.reteoo.ReteooWorkingMemory.doRetract(_ReteooWorkingMemory.jav a:76_) > > at > org.drools.common.AbstractWorkingMemory.modifyObject(_AbstractWorkingMem ory.java:940_) > > at > org.drools.base.DefaultKnowledgeHelper.modifyObject(_DefaultKnowledgeHel per.java:95_) > > at > drools.debug.Rule_Rule_4__Null_Pointer_Exception__0.consequence(_Rule_Ru le_4__Null_Pointer_Exception__0.java:8_) > > at > drools.debug.Rule_Rule_4__Null_Pointer_Exception__0ConsequenceInvoker.ev aluate(_Rule_Rule_4__Null_Pointer_Exception__0ConsequenceInvoker.java:24 _) > > at > org.drools.common.DefaultAgenda.fireActivation(_DefaultAgenda.java:467_) > at > org.drools.common.DefaultAgenda.fireNextItem(_DefaultAgenda.java:431_) > at > org.drools.common.AbstractWorkingMemory.fireAllRules(_AbstractWorkingMem ory.java:360_) > > > I have also encountered NPE in > "org.drools.reteoo.AlphaNode.retractObject" when using my actual rules > other than these simplifications put together to demonstrate the error > (both are caused by a call to "final Activation activation = > tuple.getActivation();" returning NULL so I suspect the root cause to > be common). Is this a case for a new JIRA entry or have I done > something idiotic? > > With kind regards, > > Mike > >----------------------------------------------------------------------- - > >_______________________________________________ >rules-users mailing list >[email protected] >https://lists.jboss.org/mailman/listinfo/rules-users > > -- Edson Tirelli Software Engineer - JBoss Rules Core Developer Office: +55 11 3124-6000 Mobile: +55 11 9218-4151 JBoss, a division of Red Hat @ www.jboss.com _______________________________________________ rules-users mailing list [email protected] https://lists.jboss.org/mailman/listinfo/rules-users _______________________________________________ rules-users mailing list [email protected] https://lists.jboss.org/mailman/listinfo/rules-users
