将并发请求发送到Drools时出现NullPointerException

时间:2014-08-25 07:23:02

标签: java concurrency nullpointerexception drools

在我们的应用程序中,我们有一个拦截器来为我们收到的每个请求调用drools规则。在发送多个请求时添加新的规则集(在单独的DRL文件中)后,我们获得NPE(参见下面的堆栈跟踪)。不幸的是,我不知道在哪个规则中发生这种情况,因为堆栈跟踪并没有给我很多信息:

Caused by: java.lang.NullPointerException
at org.drools.core.reteoo.BaseLeftTuple.get(BaseLeftTuple.java:500)
at org.drools.core.reteoo.QueryElementNode$UnificationNodeViewChangedEventListener.rowAdded(QueryElementNode.java:331)
at org.drools.core.phreak.PhreakQueryTerminalNode.doLeftInserts(PhreakQueryTerminalNode.java:65)
at org.drools.core.phreak.PhreakQueryTerminalNode.doNode(PhreakQueryTerminalNode.java:37)
at org.drools.core.phreak.RuleNetworkEvaluator.innerEval(RuleNetworkEvaluator.java:311)
at org.drools.core.phreak.RuleNetworkEvaluator.evalStackEntry(RuleNetworkEvaluator.java:224)
at org.drools.core.phreak.RuleNetworkEvaluator.outerEval(RuleNetworkEvaluator.java:166)
at org.drools.core.phreak.RuleNetworkEvaluator.evaluateNetwork(RuleNetworkEvaluator.java:116)
at org.drools.core.phreak.RuleExecutor.reEvaluateNetwork(RuleExecutor.java:200)
at org.drools.core.phreak.RuleExecutor.evaluateNetworkAndFire(RuleExecutor.java:67)
at org.drools.core.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:937)
at org.drools.core.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1201)
at org.drools.core.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:958)
at org.drools.core.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:932)
at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:256)
at org.drools.core.command.runtime.rule.FireAllRulesCommand.execute(FireAllRulesCommand.java:106)
at org.drools.core.command.runtime.rule.FireAllRulesCommand.execute(FireAllRulesCommand.java:32)
at org.drools.core.command.runtime.BatchExecutionCommandImpl.execute(BatchExecutionCommandImpl.java:155)
at org.drools.core.command.runtime.BatchExecutionCommandImpl.execute(BatchExecutionCommandImpl.java:76)
at org.drools.core.impl.StatelessKnowledgeSessionImpl.execute(StatelessKnowledgeSessionImpl.java:358)
at com.comp.test.validation.impl.cmprules.cmpRulesBridgeImpl.validate(cmpRulesBridgeImpl.java:154)
at com.comp.test.au.validation.impl.cmprules.CreateInvestorAccountRulesValidator.doValidation(CreateInvestorAccountRulesValidator.java:366)
at com.comp.test.validation.impl.BaseJAXBElementValidator.validate(BaseJAXBElementValidator.java:78)
at org.springframework.validation.ValidationUtils.invokeValidator(ValidationUtils.java:83)
at org.springframework.validation.ValidationUtils.invokeValidator(ValidationUtils.java:55)
at com.comp.test.ws.interceptor.RequestUnmarshallingFaultValidatingEndpointInterceptor.onRequestUnmarshalled(RequestUnmarshallingFaultValidatingEndpointInterceptor.java:85)
at com.comp.test.ws.interceptor.RequestUnmarshallingEndpointInterceptor.handleRequest(RequestUnmarshallingEndpointInterceptor.java:62)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:96)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:260)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at com.sun.proxy.$Proxy260.handleRequest(Unknown Source)
at org.springframework.ws.server.endpoint.interceptor.DelegatingSmartEndpointInterceptor.handleRequest(DelegatingSmartEndpointInterceptor.java:78)
at org.springframework.ws.server.MessageDispatcher.dispatch(MessageDispatcher.java:224)
... 22 more

为了提供更多信息,我们有4个DRL文件,其中一个名为Prerequisite,其中包含加载我们需要的东西的规则以及声明的类型和查询。还有一些规则可以更新声明的类型......声明的类型是否安全?查询怎么样?你能帮帮我吗?

不幸的是,我无法提供更多细节,因为有近100条规则,我不知道哪一条会导致此错误。

Drools 6.0.0.Final

更新:

@luane我放了一些日志,一切看起来都很正常,只是因为我不确定这个问题:

'

query calculateTotalSumInsured(List riders, String benefit, BigDecimal totalRiderSum)
    ?listRiderBenefitsByType(riders, benefit;)
    totalRiderSum := BigDecimal() from accumulate (
            ic : Cover(!("I".equals(status)))
                        from riders,
            init(BigDecimal total = BigDecimal.ZERO;),
            action( total = (ic.getActualSumInsured() != null ? total.add(ic.getActualSumInsured()) : total);),
            result(total)
    )

end'

我不确定 listRiderBenefitsByType ()之前的是什么意思... FYI:它是另一个查询。是否在并发环境中导致问题? 从Drools文档中可以看出:

  

Drools现在提供Prolog样式派生查询,作为实验性功能。这意味着一个查询或者当'规则的一部分可以通过查询元素调用查询。这也是递归的,因此查询可以调用自身。查询元素可以带有问号前缀'?'这表明我们有一个可以提取数据的模式结构,而不是模式的正常反应推送性质。如果?省略了查询将作为实时"打开查询"执行。具有反应性,类似于正常模式的工作方式。

但我不明白这是多么诚实!

0 个答案:

没有答案