PMML - Exception excuting consequence for rule xxx in yyy: java.lang.NullPointerException : using KnowledgeAgent
by smilk
Hi. I'm trying to test pmml "decision trees"
(https://github.com/droolsjbpm/drools-chance/tree/master/drools-pmml)
on Drools 5.5.0.Final.
The two test environment's outcome are not same.
1) I got a test on Eclipse. The results are fine. Test source is as below.
public class PMMLTestFromLocal {
public static final void main(String[] args) {
try {
KnowledgeBase kbase = readKnowledgeBase();
StatefulKnowledgeSession ksession =
kbase.newStatefulKnowledgeSession();
KnowledgeRuntimeLogger logger =
KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, "LocalPmmlTest");
FactType CHK_YN_Type = kbase.getFactType(
"Meritz_ModelRule_01","CHK_YN" );
CHK_YN_Type.newInstance();
ksession.getWorkingMemoryEntryPoint( "in_AC_CSE_TYP_RE"
).insert( "group0" );
ksession.getWorkingMemoryEntryPoint( "in_AC_TYP_RE" ).insert(
"Caution" );
ksession.getWorkingMemoryEntryPoint( "in_COV_CD_RE" ).insert(
"group2" );
ksession.getWorkingMemoryEntryPoint( "in_AC_STAT_CD_RE"
).insert( "group1" );
ksession.getWorkingMemoryEntryPoint( "in_HDCAP_RATE_RE"
).insert( "0" );
ksession.getWorkingMemoryEntryPoint( "in_FDS_AC_YN" ).insert(
"0" );
ksession.getWorkingMemoryEntryPoint( "in_AGE_GRD" ).insert(
"10대" );
ksession.getWorkingMemoryEntryPoint( "in_AC_COT_DAY" ).insert(
0.0 );
ksession.fireAllRules();
logger.close();
} catch (Throwable t) {
t.printStackTrace();
}
}
private static KnowledgeBase readKnowledgeBase() throws Exception {
KnowledgeBuilder kbuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource("pmml2.drl"),
ResourceType.DRL);
KnowledgeBuilderErrors errors = kbuilder.getErrors();
if (errors.size() > 0) {
for (KnowledgeBuilderError error: errors) {
System.err.println(error);
}
throw new IllegalArgumentException("Could not parse
knowledge.");
}
KnowledgeBase kbase =
KnowledgeBaseFactory.newKnowledgeBase("Meritz");
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
return kbase;
}
}
2) The Second environment which is excuting Exception is Tomcat.
I got a test using same drools engine on Tomcat. But NullpointerException
occured.
Test source is as below.
public class PMMLTestFromServer {
public static void main(String[] args) {
StatefulKnowledgeSession kSession = getSKSession();
KnowledgeRuntimeLogger logger =
KnowledgeRuntimeLoggerFactory.newFileLogger(kSession, "ServerPmmlTest");
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
kSession.getWorkingMemoryEntryPoint( "in_AC_CSE_TYP_RE" ).insert( "group0"
);
kSession.getWorkingMemoryEntryPoint( "in_AC_TYP_RE" ).insert( "Caution" );
kSession.getWorkingMemoryEntryPoint( "in_COV_CD_RE" ).insert( "group2" );
kSession.getWorkingMemoryEntryPoint( "in_AC_STAT_CD_RE" ).insert( "group1"
);
kSession.getWorkingMemoryEntryPoint( "in_HDCAP_RATE_RE" ).insert( "0" );
kSession.getWorkingMemoryEntryPoint( "in_FDS_AC_YN" ).insert( "0" );
kSession.getWorkingMemoryEntryPoint( "in_AGE_GRD" ).insert( "10대" );
kSession.getWorkingMemoryEntryPoint( "in_AC_COT_DAY" ).insert( 0.0 );
kSession.fireAllRules();
logger.close();
}
public static StatefulKnowledgeSession getSKSession() {
KnowledgeAgent agent = KnowledgeAgentFactory.newKnowledgeAgent("Meritz");
agent.applyChangeSet(ResourceFactory.newClassPathResource("change-set_model.xml"));
KnowledgeBase ruleBase = agent.getKnowledgeBase();
System.out.println(ruleBase.getKnowledgePackages());
return ruleBase.newStatefulKnowledgeSession();
}
}
The differences in two test source is using KnowledgeAgent.
Exception stack trace follows -
Exception executing consequence for rule
"outputFeature_CHK_YN_to_Probability_N_probability" in Meritz_ModelRule_01:
java.lang.NullPointerException
at
org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1297)
at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1221)
at org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1456)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:710)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:674)
at
org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:230)
at com.meritzfis.test.PMMLTestFromServer.main(PMMLTestFromServer.java:43)
Caused by: java.lang.NullPointerException
at
org.drools.base.evaluators.BeforeEvaluatorDefinition$BeforeEvaluator.evaluateCachedRight(BeforeEvaluatorDefinition.java:318)
at
org.drools.rule.constraint.EvaluatorConstraint.isAllowedCachedRight(EvaluatorConstraint.java:80)
at
org.drools.common.DoubleBetaConstraints.isAllowedCachedRight(DoubleBetaConstraints.java:97)
at org.drools.reteoo.JoinNode.propagateFromRight(JoinNode.java:156)
at org.drools.reteoo.JoinNode.assertObject(JoinNode.java:148)
at
org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:497)
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:382)
at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:235)
at org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:240)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:350)
at org.drools.common.SimpleBeliefSystem.insert(SimpleBeliefSystem.java:38)
at
org.drools.common.TruthMaintenanceSystem.addLogicalDependency(TruthMaintenanceSystem.java:204)
at
org.drools.common.TruthMaintenanceSystem.addLogicalDependency(TruthMaintenanceSystem.java:176)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:231)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:903)
at
org.drools.base.DefaultKnowledgeHelper.insertLogical(DefaultKnowledgeHelper.java:245)
at
org.drools.base.DefaultKnowledgeHelper.insertLogical(DefaultKnowledgeHelper.java:210)
at
org.drools.base.DefaultKnowledgeHelper.insertLogical(DefaultKnowledgeHelper.java:205)
at
Meritz_ModelRule_01.Rule_outputFeature_CHK_YN_to_Probability_N_probability_a4a43fe942664fe0b31e45a29a6d99fc.defaultConsequence(Rule_outputFeature_CHK_YN_to_Probability_N_probability_a4a43fe942664fe0b31e45a29a6d99fc.java:14)
at
Meritz_ModelRule_01.Rule_outputFeature_CHK_YN_to_Probability_N_probability_a4a43fe942664fe0b31e45a29a6d99fcDefaultConsequenceInvokerGenerated.evaluate(Unknown
Source)
at
Meritz_ModelRule_01.Rule_outputFeature_CHK_YN_to_Probability_N_probability_a4a43fe942664fe0b31e45a29a6d99fcDefaultConsequenceInvoker.evaluate(Unknown
Source)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1287)
... 6 more
I'm attaching a drl file.
--
View this message in context: http://drools.46999.n3.nabble.com/PMML-Exception-excuting-consequence-for...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 9 months
java.lang.ClassCastException: org.drools.reteoo.BetaMemory cannot be cast to org.drools.reteoo.AlphaNode$AlphaMemory
by dcrissman
Does this mean anything to anyone?
I found this, but I am using 5.5.0.Final:
http://drools.46999.n3.nabble.com/org-drools-reteoo-AlphaNode-AlphaMemory...
java.lang.ClassCastException: org.drools.reteoo.BetaMemory cannot be cast to
org.drools.reteoo.AlphaNode$AlphaMemory
at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:136)
at
org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:497)
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:382)
at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:141)
at
org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:497)
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:382)
at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:235)
at org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:240)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:350)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:311)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:903)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:847)
at
org.drools.impl.StatefulKnowledgeSessionImpl.insert(StatefulKnowledgeSessionImpl.java:269)
...
--
View this message in context: http://drools.46999.n3.nabble.com/java-lang-ClassCastException-org-drools...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 9 months
Timer and AgendaFilter
by Kai Ruddies
Hi,
I have a rule with a timer and call fireAllRules(AgendaFilter agendaFilter) with an AgendaFilter. I can see the Activation is fired after the delay but accept(Activation activation) in my AgendaFilter isn't invoked. My AgendaFilter is working well for other rules without timers.
Is this a bug or wanted that ScheduledActivations aren't passed to the AgendaFilter?
I'm using drools expert 5.5.0.Final.
Thanks,
Kai
12 years, 9 months
Dublin : JBoss BRMS event Wed 28th Aug
by Mark Proctor
I'll be giving a "JBoss BRMS 6.0" talk in Dublin this month, it's free, so please help spread the word ;)
http://marketing.interactiveideas.com/acton/fs/blocks/showLandingPage/a/8...
---
JBoss® BRMS Technical Workshop
In this FREE Technical Workshop on Wednesday 28th August at the Westin Dublin Hotel, you will discover how the JBoss Business Rules Management System (BRMS) allows you to automate, manage and improve your critical business processes and policies.
Learn how other organisations are benefiting from maintaining business processes and policies outside of application code; and explore emerging developments and the technology roadmap withMark Proctor, Red Hat's Worldwide Technical Lead for BRMS.
Places are limited, so register early to avoid disappointment.
12 years, 9 months
How to avoid stateless session rule fire on every fact ?
by viraj
Hi all,
In my project I have 20,000 rules to reason with 20,000 facts. The rules are
embedded in facts. Therefore for each rule , there is one fact object which
that rule belongs to. I'm using following condition to find this matching
object.
rule "Book Rule 1 - 187970786749253 "
no-loop true
when
$book : Book( bookId == 187970786749253 , $eligible : eligible == false )
UserProfile( userType == UserType.STUDENT , status == 1 ) //... other
conditions
then
//Do something here...
end
So above rule is belongs to Book object which has id = 187970786749253 (
This is a unique id ). I'm using stateless sequential rule engine.
Following is the my understanding how rules are executed over facts.
For first rule it needs to check all the 20,000 objects in worst case to
find matching Book. For second rule the worst case should be 19,999 object
search since one object is found and processed. But I used
AgendaEventListener to find the time for each rule. It has nearly constant
time for each rule , which means for each rule, engine search all the 20,000
object. I need to avoid this still keeping stateless session. Any ideas how
to do this ?
Thanks !
--
View this message in context: http://drools.46999.n3.nabble.com/How-to-avoid-stateless-session-rule-fir...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 9 months
How do you explicitly uses a designated DSL file when parsing dslr?
by Sonata
Hi, I have added more than one DSL files into the KnowledgeBase (with
conflicting definitions).
It seems that even though I have stated expander A.dsl or expander B.dsl in
my dslr
it still uses the first dsl that I added into the KnowledgeBase then the
second dsl to parse my dslr.
Meaning that the definitions in A.dsl persisted when it comes to conflicting
definitions.
Is "expander" there for other purpose or there is simply no way to specific
which dsl to use?
Otherwise how do you specific any dsl for your dslr except to create a new
KnowledgeBuilder each time the dslr is required and add only the dsl it
needs by looking into the dslr file?
I am using 5.5.0.Final, thank you!
--
View this message in context: http://drools.46999.n3.nabble.com/How-do-you-explicitly-uses-a-designated...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 9 months
RightTupleIndexHashTable
by Ming Fang
What is the purpose of RightTupleIndexHashTable?
We are getting the exception below but unable to come up with a self contained unit test to demonstrate the problem.
Caused by: java.lang.NullPointerException: null
at org.drools.core.util.index.RightTupleIndexHashTable.removeAdd(RightTupleIndexHashTable.java:344) ~[drools-core-5.5.0.Final.jar:5.5.0.Final]
at org.drools.reteoo.JoinNode.modifyRightTuple(JoinNode.java:224) ~[drools-core-5.5.0.Final.jar:5.5.0.Final]
at org.drools.reteoo.PropagationQueuingNode$ModifyToSinkAction.execute(PropagationQueuingNode.java:513) ~[drools-core-5.5.0.Final.jar:5.5.0.Final]
at org.drools.reteoo.PropagationQueuingNode.propagateActions(PropagationQueuingNode.java:280) ~[drools-core-5.5.0.Final.jar:5.5.0.Final]
at org.drools.reteoo.PropagationQueuingNode$PropagateAction.execute(PropagationQueuingNode.java:588) ~[drools-core-5.5.0.Final.jar:5.5.0.Final]
at org.drools.common.AbstractWorkingMemory.executeQueuedActions(AbstractWorkingMemory.java:993) [drools-core-5.5.0.Final.jar:5.5.0.Final]
12 years, 9 months
Drools time to insert facts
by Bojan Janisch
Hey guys,
is it normal to wait hours or to get out of memory error, for a rule which checks for 5 or 6 objects? No constraints, just simple checking for objects in working memory.
Greetings
Bojan
12 years, 9 months
ruleflow-group and jBPMN
by droolster
Hello,
Please can the community help me.
I have setup a Drools JBPMN process and am using it to determine which set
of rules to fire under different scenarios.
However, when I add the ruleflow-group attribute to the rules in the DRL
file, the rules fail to execute.
Here is my setup:
foo.bpmn2
RuleFlowGroup="abc"
rules.drl
rule "number one" ruleflow-group "abc"
When I initiate the process, the rule do not fire. If I take out the
ruleflow-group attribute in the DRL file, the rules fire. Any idea what I am
not doing or doing wrong?
Regards.
--
View this message in context: http://drools.46999.n3.nabble.com/ruleflow-group-and-jBPMN-tp4025347.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 9 months