FYI: I tested my application with the latest Drools release 5.2.0.Final and I couldn’t reproduce the problem described below. It seems that it is solved.

 

Best regards,

Wolfgang

 

 

Von: rules-users-bounces@lists.jboss.org [mailto:rules-users-bounces@lists.jboss.org] Im Auftrag von Weiss, Wolfgang
Gesendet: Dienstag, 21. Juni 2011 10:19
An: rules-users@lists.jboss.org
Betreff: [rules-users] NullPointerException in RightTupleIndexHashTable.remove()

 

Hi all!

 

I encountered that null pointer exceptions occur when retracting an object from the working memory. Sometimes the problem occurs sooner sometimes later but it certainly happens. I think it also depends on the workload on the machine. Sometimes the NPE is thrown in 'LeftTupleIndexHashTable' but mainly in 'RightTupleIndexHashTable'. After the exception is thrown, the object to retract is still in the working memory. When I remove the line 'retract($obj)' in my rule, I don't get an exception.

 

The problem occurs mainly in this rule, but also in other rules:

rule "remove a cross talk"

  agenda-group "evaluation"

  activation-group "ag-crossTalk"

  lock-on-active true

  salience 40

     

  when

    $ctf  : CrossTalkFact($persID : uniquePersonID, $ctfTimestamp : timestamp)

    $pers : AnalysisCue(cueType == AnalysisCue.ACTION_STOP_TALKING, uniquePersonID == $persID, timestamp > $ctfTimestamp) from entry-point "LowLevelCueStream"

  then

    retract($ctf); //the suspicious line

    //... do some other things

end

 

My configuration:

drools.dialect.java.compiler = JANINO

 EventProcessingOption = STREAM

 

I was able to reproduce the problem with following versions:

5.1.1

 5.2.0.M1

 5.2.0.CR1

 

 

Stack trace from the version: 5.2.0.CR1

org.drools.runtime.rule.ConsequenceException: rule: remove a cross talk

                at org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)

                at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:915)

                at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:844)

                at org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1055)

                at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:733)

                at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:699)

                at org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:218)

                ...

Caused by: java.lang.NullPointerException

                at org.drools.core.util.RightTupleIndexHashTable.remove(RightTupleIndexHashTable.java:351)

                at org.drools.reteoo.NotNode.retractRightTuple(NotNode.java:178)

                at org.drools.reteoo.ObjectTypeNode.retractObject(ObjectTypeNode.java:235)

                at org.drools.reteoo.EntryPointNode.retractObject(EntryPointNode.java:229)

                at org.drools.common.NamedEntryPoint.retract(NamedEntryPoint.java:529)

                at org.drools.base.DefaultKnowledgeHelper.retract(DefaultKnowledgeHelper.java:226)

                at eu.ta2.orchestration.engine.cueLifter.Rule_remove_a_cross_talk_0.defaultConsequence(Unknown Source)

                at eu.ta2.orchestration.engine.cueLifter.Rule_remove_a_cross_talk_0DefaultConsequenceInvoker.evaluate(Unknown Source)

                at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:905)

                ... 31 more

 

 

Sometimes the exception occurs in the LeftTupleIndexHashTable:

org.drools.runtime.rule.ConsequenceException: rule: remove a cross talk

                at org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)

                at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:915)

                at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:844)

                at org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1055)

                at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:733)

                at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:699)

                at org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:218)

                ...

Caused by: java.lang.NullPointerException

                at org.drools.core.util.LeftTupleIndexHashTable.remove(LeftTupleIndexHashTable.java:275)

                at org.drools.reteoo.NotNode.retractLeftTuple(NotNode.java:231)

                at org.drools.reteoo.SingleLeftTupleSinkAdapter.doPropagateRetractLeftTuple(SingleLeftTupleSinkAdapter.java:212)

                at org.drools.reteoo.SingleLeftTupleSinkAdapter.propagateRetractLeftTuple(SingleLeftTupleSinkAdapter.java:86)

                at org.drools.reteoo.JoinNode.retractLeftTuple(JoinNode.java:210)

                at org.drools.reteoo.SingleLeftTupleSinkAdapter.doPropagateRetractLeftTuple(SingleLeftTupleSinkAdapter.java:212)

                at org.drools.reteoo.SingleLeftTupleSinkAdapter.propagateRetractRightTuple(SingleLeftTupleSinkAdapter.java:119)

                at org.drools.reteoo.JoinNode.retractRightTuple(JoinNode.java:192)

                at org.drools.reteoo.ObjectTypeNode.retractObject(ObjectTypeNode.java:235)

                at org.drools.reteoo.EntryPointNode.retractObject(EntryPointNode.java:229)

                at org.drools.common.NamedEntryPoint.retract(NamedEntryPoint.java:529)

                at org.drools.base.DefaultKnowledgeHelper.retract(DefaultKnowledgeHelper.java:226)

                at eu.ta2.orchestration.engine.cueLifter.Rule_remove_a_cross_talk_0.defaultConsequence(Unknown Source)

                at eu.ta2.orchestration.engine.cueLifter.Rule_remove_a_cross_talk_0DefaultConsequenceInvoker.evaluate(Unknown Source)

                at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:905)

                ... 31 more

 

 

Any help is appreciated.

 

Best regards,

Wolfgang