I also was getting this error. I brought out package building logic to execute once, and
KnowledgeSession realted logic to repeat the required number of times.
Seems there required some delay in preparing rules related classes into one package during
iteration. Above step was working fine for me.
Pseudo code:
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
// this will parse and compile in one step
// get the compiled packages (which are serializable)
Collection<KnowledgePackage> pkgs = null;
// add the packages to a knowledgebase (deploy the knowledge packages).
KnowledgeBase kbase = null;
StatefulKnowledgeSession ksession = null;
// constructor to be called once
public RuleEngine (byte[] rules) {
kbuilder.add(ResourceFactory.newByteArrayResource(rules),ResourceType.DRL);
// Check the builder for errors
if (kbuilder.hasErrors()) {
System.out.println(kbuilder.getErrors().toString());
throw new RuntimeException("Unable to compile drl.");
}
pkgs = kbuilder.getKnowledgePackages();
// add the packages to a knowledgebase (deploy the knowledge packages).
kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages(pkgs);
}
// this method will be called required number of times
public void fire(Object obj) {
ksession = kbase.newStatefulKnowledgeSession();
ksession.addEventListener(new DebugAgendaEventListener());
ksession.addEventListener(new DebugWorkingMemoryEventListener());
// setup the audit logging
//KnowledgeRuntimeLogger logger =
KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, "log/drools.log");
ksession.insert(obj);
ksession.fireAllRules();
//logger.close();
ksession.dispose();
}
Check this out.
Thanks & Regards
Santhosh
From: rules-users-bounces(a)lists.jboss.org [mailto:rules-users-bounces@lists.jboss.org] On
Behalf Of Wolfgang Laun
Sent: Tuesday, September 27, 2011 4:10 PM
To: Rules Users List
Subject: Re: [rules-users] Getting Exception while running rules continuously on the Event
Streams from Mule Component.
Drools version?
Looks like a bug, I've seen similar NPE reports.
-W
On 27 September 2011 12:23, Hari Kishan
<HariKishan.Tammana@pass-consulting.com<mailto:HariKishan.Tammana@pass-consulting.com>>
wrote:
Please find attached the rule Code (.drl) below.
Frequently getting this below Exception while running rules.
Exception caught while executing action:
org.drools.reteoo.PropagationQueuingNode$PropagateAction@41c317<mailto:org.drools.reteoo.PropagationQueuingNode$PropagateAction@41c317>
java.lang.NullPointerException
at org.drools.util.LeftTupleList.toArray(LeftTupleList.java:106)
at org.drools.util.LeftTupleList.toArray(LeftTupleList.java:11)
at org.drools.reteoo.CollectNode.assertObject(CollectNode.java:256)
at
org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:42)
at
org.drools.reteoo.RightInputAdapterNode.assertLeftTuple(RightInputAdapterNode.java:135)
at
org.drools.reteoo.SingleLeftTupleSinkAdapter.doPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:117)
at
org.drools.reteoo.SingleLeftTupleSinkAdapter.propagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:28)
at org.drools.reteoo.FromNode.evaluateAndPropagate(FromNode.java:156)
at org.drools.reteoo.FromNode.assertLeftTuple(FromNode.java:104)
at
org.drools.reteoo.CompositeLeftTupleSinkAdapter.doPropagateAssertLeftTuple(CompositeLeftTupleSinkAdapter.java:145)
at
org.drools.reteoo.CompositeLeftTupleSinkAdapter.propagateAssertLeftTuple(CompositeLeftTupleSinkAdapter.java:39)
at org.drools.reteoo.JoinNode.assertObject(JoinNode.java:175)
at
org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:42)
at
org.drools.reteoo.PropagationQueuingNode$AssertAction.execute(PropagationQueuingNode.java:326)
at
org.drools.reteoo.PropagationQueuingNode.propagateActions(PropagationQueuingNode.java:221)
at
org.drools.reteoo.PropagationQueuingNode$PropagateAction.execute(PropagationQueuingNode.java:394)
at
org.drools.common.AbstractWorkingMemory.executeQueuedActions(AbstractWorkingMemory.java:1486)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:158)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:122)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:80)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:28)
at org.mule.module.drools.Drools.assertEvent(Drools.java:165)
at org.mule.module.bpm.Rules.handleEvent(Rules.java:131)
at org.mule.module.bpm.RulesComponent.doInvoke(RulesComponent.java:84)
at
org.mule.component.AbstractComponent.invokeInternal(AbstractComponent.java:120)
at
org.mule.component.AbstractComponent.access$000(AbstractComponent.java:56)
at
org.mule.component.AbstractComponent$1$1.process(AbstractComponent.java:234)
at
org.mule.processor.chain.DefaultMessageProcessorChain.doProcess(DefaultMessageProcessorChain.java:88)
at
org.mule.processor.chain.AbstractMessageProcessorChain.process(AbstractMessageProcessorChain.java:89)
at
org.mule.processor.chain.InterceptingChainLifecycleWrapper.doProcess(InterceptingChainLifecycleWrapper.java:63)
at
org.mule.processor.chain.AbstractMessageProcessorChain.process(AbstractMessageProcessorChain.java:89)
at
org.mule.processor.chain.InterceptingChainLifecycleWrapper.process(InterceptingChainLifecycleWrapper.java:94)
at
org.mule.component.AbstractComponent.process(AbstractComponent.java:154)
at
org.mule.processor.AbstractInterceptingMessageProcessor.processNext(AbstractInterceptingMessageProcessor.java:93)
at
org.mule.interceptor.AbstractEnvelopeInterceptor.process(AbstractEnvelopeInterceptor.java:55)
at
org.mule.processor.AsyncInterceptingMessageProcessor.processNextTimed(AsyncInterceptingMessageProcessor.java:118)
at
org.mule.processor.SedaStageInterceptingMessageProcessor$SedaStageWorker.doWork(SedaStageInterceptingMessageProcessor.java:197)
at
org.mule.processor.SedaStageInterceptingMessageProcessor$SedaStageWorker.doRun(SedaStageInterceptingMessageProcessor.java:178)
at
org.mule.work.AbstractMuleEventWork.run(AbstractMuleEventWork.java:43)
at org.mule.work.WorkerContext.run(WorkerContext.java:309)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
http://drools.46999.n3.nabble.com/file/n3372189/sensors.drl sensors.drl
--
View this message in context:
http://drools.46999.n3.nabble.com/Getting-Exception-while-running-rules-c...
Sent from the Drools: User forum mailing list archive at
Nabble.com.
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org<mailto:rules-users@lists.jboss.org>
https://lists.jboss.org/mailman/listinfo/rules-users