Uploaded image for project: 'Drools'
  1. Drools
  2. DROOLS-1686

NPE using drools accumulate function in fairness constraint (tennis example)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 7.2.0.Final
    • 7.1.0.Final
    • core engine
    • None

      Using the LoadBalanceAccumulateFunction found in tennis example for modelling fairness constraints leads to NPE in drools itself, in FromNodeLeftTuple.java:

      Caused by: java.lang.NullPointerException
          at org.drools.core.reteoo.FromNodeLeftTuple.getAccumulatedObjects(FromNodeLeftTuple.java:98)
      

      Full stacktrace:

      Exception executing consequence for rule "fairAssignmentCountPerTeam" in org.optaplanner.examples.tennis.solver: java.lang.NullPointerException
          at org.drools.core.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)
          at org.drools.core.common.DefaultAgenda.handleException(DefaultAgenda.java:1252)
          at org.drools.core.phreak.RuleExecutor.innerFireActivation(RuleExecutor.java:438)
          at org.drools.core.phreak.RuleExecutor.fireActivation(RuleExecutor.java:379)
          at org.drools.core.phreak.RuleExecutor.fire(RuleExecutor.java:135)
          at org.drools.core.phreak.RuleExecutor.evaluateNetworkAndFire(RuleExecutor.java:88)
          at org.drools.core.concurrent.AbstractRuleEvaluator.internalEvaluateAndFire(AbstractRuleEvaluator.java:34)
          at org.drools.core.concurrent.SequentialRuleEvaluator.evaluateAndFire(SequentialRuleEvaluator.java:43)
          at org.drools.core.common.DefaultAgenda.fireLoop(DefaultAgenda.java:1068)
          at org.drools.core.common.DefaultAgenda.internalFireAllRules(DefaultAgenda.java:1015)
          at org.drools.core.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1007)
          at org.drools.core.impl.StatefulKnowledgeSessionImpl.internalFireAllRules(StatefulKnowledgeSessionImpl.java:1320)
          at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1311)
          at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1295)
          at org.optaplanner.core.impl.score.director.drools.DroolsScoreDirector.calculateScore(DroolsScoreDirector.java:117)
          at org.optaplanner.test.impl.score.AbstractScoreVerifier.assertWeight(AbstractScoreVerifier.java:82)
          at org.optaplanner.test.impl.score.buildin.hardmediumsoft.HardMediumSoftScoreVerifier.assertSoftWeight(HardMediumSoftScoreVerifier.java:107)
          at org.optaplanner.test.impl.score.buildin.hardmediumsoft.HardMediumSoftScoreVerifier.assertSoftWeight(HardMediumSoftScoreVerifier.java:94)
          at org.optaplanner.examples.tennis.TennisConstraintsTest.fairAssignmentCountPerTeam(TennisConstraintsTest.java:40)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:498)
          at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
          at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
          at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
          at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
          at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
          at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
          at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
          at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
          at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
          at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
          at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
          at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
          at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
          at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
          at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
          at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)
          at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
          at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
      Caused by: java.lang.NullPointerException
          at org.drools.core.reteoo.FromNodeLeftTuple.getAccumulatedObjects(FromNodeLeftTuple.java:98)
          at org.drools.core.common.AgendaItem.getObjectsDeep(AgendaItem.java:78)
          at org.drools.core.reteoo.RuleTerminalNodeLeftTuple.getObjectsDeep(RuleTerminalNodeLeftTuple.java:359)
          at org.optaplanner.core.api.score.holder.AbstractScoreHolder.extractJustificationList(AbstractScoreHolder.java:118)
          at org.optaplanner.core.api.score.holder.AbstractScoreHolder.registerConstraintMatch(AbstractScoreHolder.java:88)
          at org.optaplanner.core.api.score.buildin.hardmediumsoft.HardMediumSoftScoreHolder.addMediumConstraintMatch(HardMediumSoftScoreHolder.java:69)
          at org.optaplanner.examples.tennis.solver.Rule_fairAssignmentCountPerTeam1005511081.defaultConsequence(Rule_fairAssignmentCountPerTeam1005511081.java:21)
          at org.optaplanner.examples.tennis.solver.Rule_fairAssignmentCountPerTeam1005511081DefaultConsequenceInvokerGenerated.evaluate(Unknown
      Source)
          at org.optaplanner.examples.tennis.solver.Rule_fairAssignmentCountPerTeam1005511081DefaultConsequenceInvoker.evaluate(Unknown
      Source)
      at org.drools.core.phreak.RuleExecutor.innerFireActivation(RuleExecutor.java:431)
      ... 38 more 
      

      See also related discussion in: https://groups.google.com/forum/#!topic/optaplanner-dev/xA6IdGieDpU

              mfusco@redhat.com Mario Fusco
              mmueller_jira Markus Müller (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: