drools 5:跨进程共享KnowledgeBase时出现NullPointerException

时间:2012-12-05 19:35:36

标签: drools mvel

我们有一组运行drools的jboss实例。我们在一个实例上生成KnowledgeBase,然后将其存储在数据库中;然后其他实例可以从数据库加载它而不是自己生成它。

使用drools 4已经有一段时间了,但是我们最近升级到drools 5.3.0 BRMS并且模式不再有效。 KnowledgeBase在生成它的应用程序实例中运行良好,但在其他任何地方都失败,并出现以下异常。请注意,在将事实插入工作内存时会发生此异常。

应用程序的所有实例都是相同的,它们在同一个jvm等中运行。'其他'实例不需要在不同的物理机器上 - 它可以在同一硬件上,并且仍然会发生故障。

知识库是什么让它在与生成它的jvm实例不同的jvm实例中失败?有没有办法避免这个问题?感谢。

这是故障似乎发生的drl。我已经通过mvel代码进行了一些调试,但我对它并不熟悉,而且我还没有弄清楚发生了什么。我认为发生故障的表达方式是' this.fact.requirementId'。

rule "Find OutOfOrder PredicateSolutions for new LeafPredicateSolution in rule [Become Application Expired : 147]"
ruleflow-group "RuleGroup[Become Application Expired:147]"
agenda-group "leaf"
no-loop
salience -1001
when
    EngineDates($rewindToDate: engineEffectiveDate);

    lps:LeafPredicateSolution(
        ruleId==147,
        parent==null,
        $candidateId:candidateId,
        defunct==false,
        fact:fact,
        effectiveDate == $rewindToDate,
        $programId:programId,
        eval(!fact.getReused())); // only solutions created for the fact we're running on can trigger OoO


  oops : ArrayList() from accumulate(
    PredicateSolution(
      $sol:this,
      candidateId==$candidateId,
      effectiveDate > $rewindToDate,
      defunct==false,
      programId==$programId,
      parent!=null,
      solutionType!=SolutionType.RETIRED,
      eval(($sol instanceof LeafPredicateSolution) || ($sol instanceof NonCalcProgramSolutionChild))
    ),
    init(ArrayList items = new ArrayList();),
    action(items.add($sol);),
    reverse(items.remove($sol);),
    result(items));
    // Find ProgramPredicateSolutions in other programs that refer to this program.
    // These need to be rewound.
    oopps:ArrayList() from collect(
        ProgramPredicateSolution(
            this.fact.requirementId == $programId,
            candidateId==$candidateId,
            effectiveDate > $rewindToDate,
            defunct==false,
            parent!=null,
            solutionType!=SolutionType.RETIRED));

    eval((oops.size() > 0) || (oopps.size() > 0));

    eval(predicateSolutionFactory.oopEnabled());//Don't run oop if it is disabled (TimeMachine, Whatif)

then
    predicateSolutionFactory.addToOutOfOrder(lps, oops, oopps, new Long(65));
end

堆栈追踪:

java.lang.NullPointerException
        at org.mvel2.MVEL.executeExpression(MVEL.java:954)
        at org.drools.base.extractors.MVELClassFieldReader.getValue(MVELClassFieldReader.java:100)
        at org.drools.base.extractors.BaseObjectClassFieldReader.getHashCode(BaseObjectClassFieldReader.java:196)
        at org.drools.core.util.AbstractHashTable$DoubleCompositeIndex.hashCodeOf(AbstractHashTable.java:616)
        at org.drools.core.util.RightTupleIndexHashTable.getOrCreate(RightTupleIndexHashTable.java:451)
        at org.drools.core.util.RightTupleIndexHashTable.add(RightTupleIndexHashTable.java:332)
        at org.drools.reteoo.AccumulateNode.assertObject(AccumulateNode.java:263)
        at org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:458)
        at org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:386)
        at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:135)
        at org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:59)
        at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:135)
        at org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:59)
        at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:135)
        at org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:458)
        at org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:376)
        at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:214)
        at org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:244)
        at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:337)
        at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:298)
        at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:887)
        at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:846)
        at org.drools.impl.StatefulKnowledgeSessionImpl.insert(StatefulKnowledgeSessionImpl.java:267)

0 个答案:

没有答案