0

I'm getting a null pointer exception when using optaplanner with a drools set up. this happens in org.drools.core.rule.constraint.MvelConstraint.java in the method evaluate. the null object is leftTuple:

    protected boolean evaluate(InternalFactHandle handle, InternalWorkingMemory workingMemory, LeftTuple leftTuple) {
    if (!jitted) {
        if (conditionEvaluator == null) {
            createMvelConditionEvaluator(workingMemory);
            if (TEST_JITTING && !isDynamic) { // Only for test purposes
                boolean mvelValue = forceJitEvaluator(handle, workingMemory, leftTuple);
            }
        }

        if (!TEST_JITTING && !isDynamic && invocationCounter.getAndIncrement() == JIT_THRESOLD) {
            jitEvaluator(handle, workingMemory, leftTuple);
        }
    }
    return conditionEvaluator.evaluate(handle, workingMemory, leftTuple);
}

Any ideas what might cause this? Geoffrey?

David H.
  • 953
  • 1
  • 8
  • 20
ido flax
  • 528
  • 1
  • 10
  • 19
  • No usage of `leftTuple` in that method will cause an NPE directly. It is happening below this method. – Andy Turner Feb 25 '16 at 15:36
  • 1
    If you would be so kind to verify it's still there in `6.4.0.Beta2` and then [create a JIRA issue for drools](https://issues.jboss.org/projects/DROOLS) and include a way to reproduce is (usually the DRL and domain class(es) is enough), or at least the stacktrace. Link it here and I 'll chase it for `6.4.0.CR1` (which is coming soon). – Geoffrey De Smet Feb 25 '16 at 16:00
  • Yes andy you are right, it's caused below but unknown source: at ConditionEvaluatoreaa3997683d949e28ce6eaf6feca0ced.evaluate(Unknown Source) at org.drools.core.rule.constraint.MvelConstraint.evaluate(MvelConstraint.java:258) – ido flax Feb 26 '16 at 11:24
  • 1
    Here's the JIRA issue Geoffrey, thanks! https://issues.jboss.org/browse/PLANNER-541 – ido flax Feb 26 '16 at 11:30
  • Ok, it turns out improving that error message is not a simple as I thought - we're working on that though. Meanwhile, I suggest to comment out the rules until you've found the offending rule: it shouln't be to hard to figure out the cause of the NPE then. Know that all planning variables start out as null originally, so many rules have a pattern like `Assignement(var != null, var.type == "type A")` to avoid an NPE in var.type – Geoffrey De Smet Feb 26 '16 at 15:34

0 Answers0