[
https://jira.jboss.org/jira/browse/JBRULES-1765?page=com.atlassian.jira.p...
]
Mark Proctor closed JBRULES-1765.
---------------------------------
Resolution: Done
Agenda.getScheduledActivations() method is throwing
NullPointerException
------------------------------------------------------------------------
Key: JBRULES-1765
URL:
https://jira.jboss.org/jira/browse/JBRULES-1765
Project: JBoss Drools
Issue Type: Bug
Security Level: Public(Everyone can see)
Components: drools-core (expert)
Affects Versions: 4.0.4, 4.0.5, 4.0.6, 4.0.7
Environment: Hardware: Intel P4 3.2GHz
OS: Windows XP Professional Version 2002 SP3
Reporter: Ganesh Patkar
Assignee: Mark Proctor
Fix For: 5.0.0.M5
Attachments: RuleDemo.java
I have a init rule in which i am accessing Agenda.getScheduledActivations() method. But
it throws NullPointerException. I have tried with both drools-core 4.0.4 and drools-core
4.0.7 jar files.
Here are the rules:
package com.demo.rules;
import java.util.Date;
import org.drools.Agenda;
import org.drools.spi.Activation;
import com.demo.metric.TxInfo;
import com.demo.rules.RuleDemo;
function void removeActivationsForRule(String ruleName, Agenda agenda) {
Activation[] actArr;
Activation act;
int len;
try {
actArr = agenda.getScheduledActivations();
len = actArr.length;
System.out.println("*** Scheduled Activation[] Length : " +
len);
for(int i=0;i<len;++i) {
act = actArr[i];
if(act.getRule().getName().equals(ruleName)) {
System.out.println("*** ACTIVATION : " + act +
" IS REMOVED ***");
act.remove();
}
}
} catch (NullPointerException ex) {
System.out.println("##############");
ex.printStackTrace();
System.out.println("##############");
}
}
rule 'init_rule1'
salience 10
when TxInfo(totalTime <= 100)
then
removeActivationsForRule("rule1",
drools.getWorkingMemory().getAgenda());
end
rule 'rule1'
duration 60000
when TxInfo(totalTime > 100)
then
System.out.println("**** FIRING RULE : rule1 : -" + new Date() +
"- ****");
end
Here is the stack trace:
##############
java.lang.NullPointerException
at
org.drools.common.DefaultAgenda.getScheduledActivations(DefaultAgenda.java:351)
at com.demo.rules.RuleDemo.removeScheduledActivations(RuleDemo.java:132)
at com.demo.rules.RuleDemo.beforeActivationFired(RuleDemo.java:175)
at
org.drools.event.AgendaEventSupport.fireBeforeActivationFired(AgendaEventSupport.java:103)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:540)
at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:518)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:475)##############
##############
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:439)
at com.demo.rules.RuleDemo.fireRule(RuleDemo.java:116)
at com.demo.rules.RuleDemo.main(RuleDemo.java:221)
java.lang.NullPointerException
at
org.drools.common.DefaultAgenda.getScheduledActivations(DefaultAgenda.java:351)
at
com.demo.rules.RemoveActivationsForRule.removeActivationsForRule(RemoveActivationsForRule.java:27)
at com.demo.rules.Rule_init_rule1_0.consequence(Rule_init_rule1_0.java:7)
at
com.demo.rules.Rule_init_rule1_0ConsequenceInvoker.evaluate(Rule_init_rule1_0ConsequenceInvoker.java:22)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:554)
at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:518)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:475)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:439)
at com.demo.rules.RuleDemo.fireRule(RuleDemo.java:116)
at com.demo.rules.RuleDemo.main(RuleDemo.java:221)
##############
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira