[jboss-jira] [JBoss JIRA] (DROOLS-978) java.lang.NullPointerException at org.drools.core.reteoo.NodeTypeEnums.isBetaNode(NodeTypeEnums.java:88)
bing yang (JIRA)
issues at jboss.org
Thu Nov 12 22:46:00 EST 2015
[ https://issues.jboss.org/browse/DROOLS-978?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
bing yang updated DROOLS-978:
-----------------------------
Steps to Reproduce:
Here is the test class:
------------------------------------------------------------------------------------------------
KieServices ks = KieServices.Factory.get();
KieFileSystem kfs = ks.newKieFileSystem();
ReleaseId releaseId = ks.newReleaseId(rulepackage, "ruleEngine",
"1.0.0-SNAPSHOT");
kfs.generateAndWritePomXML(releaseId);
KieModuleModel kModuleModel = ks.newKieModuleModel();
kModuleModel.newKieBaseModel("_" + rulepackage)
.setDefault(true)
.setEventProcessingMode(EventProcessingOption.STREAM);
kfs.writeKModuleXML(kModuleModel.toXML());
String rulePath = "src/main/resources/test/";
kfs.write(rulePath + "testRule.drl", rulescript);
KieBuilder kb = ks.newKieBuilder(kfs);
kb.buildAll();
if (kb.getResults().hasMessages(Level.ERROR))
{
System.out.println(kb.getResults());
}
KieContainer kContainer = ks.newKieContainer(releaseId);
KieSessionConfiguration ksconf = ks.newKieSessionConfiguration();
ksconf.setOption(TimedRuleExectionOption.YES);
KieBase kieBase = kContainer.getKieBase("_" + rulepackage);
KieSession session = kieBase.newKieSession(ksconf, null);
session.fireAllRules();
Thread.sleep(5000);
kfs.delete(rulePath + "testRule.drl");
KieBuilder kb1 = ks.newKieBuilder(kfs);
kb1.buildAll();
kContainer.updateToVersion(releaseId);
kfs.write(rulePath + "testRule.drl", rulescript1);
kb1 = ks.newKieBuilder(kfs);
kb1.buildAll();
kContainer.updateToVersion(releaseId);
session.fireAllRules();
-----------------------------------------------------------------------
rulescript:
package com.test
import com.test.RuleCheckEvent
import com.test.TimeConditionEvent
declare RuleCheckEvent
@role(event)
end
declare TimeConditionEvent
@role(event)
@expires(60s)
end
rule "Timer_icc-rule-01-12-669c-151109035449039"
timer (int:0s 60s)
salience 9999
no-loop true
enabled true
when
then
RuleCheckEvent checkEvent = new RuleCheckEvent("a7f669c150e9da7c8a13f","icc-rule-01-12-669c-151109035449039");
insert(checkEvent);
update(checkEvent);
end
rule "Timer0_icc-rule-01-12-669c-151109035449039"
timer (cron:0 */5 * * * ?)
salience 999
no-loop true
enabled true
when
then
insert(new TimeConditionEvent("icc-rule-01-12-669c-151109035449039",0,"*/5,*,*,*,?",System.currentTimeMillis()));
end
-----------------------------------------------------------------------
rulescript1:
package com.test
import com.test.RuleCheckEvent
declare RuleCheckEvent
@role(event)
end
rule "Timer_icc-rule-01-12-669c-151109040433041"
timer (int:0s 60s)
salience 9999
no-loop true
enabled true
when
then
RuleCheckEvent checkEvent = new RuleCheckEvent("a7f669c150e9da7c8a13f","icc-rule-01-12-669c-151109040433041");
insert(checkEvent);
update(checkEvent);
end
-------------------------------------------------------
package com.test;
import org.kie.api.definition.type.Role;
import org.kie.api.definition.type.Role.Type;
@Role(Type.EVENT)
public abstract class Event
{
protected String id;
protected long timestamp;
public String getId()
{
return id;
}
public void setId(String id)
{
this.id = id;
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + ((id == null) ? 0 : id.hashCode());
result = prime * result + (int) (timestamp ^ (timestamp >>> 32));
return result;
}
@Override
public boolean equals(Object obj)
{
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Event other = (Event) obj;
if (id == null)
{
if (other.id != null)
return false;
}
else if (!id.equals(other.id))
return false;
if (timestamp != other.timestamp)
return false;
return true;
}
public long getTimestamp()
{
return timestamp;
}
public void setTimestamp(long timestamp)
{
this.timestamp = timestamp;
}
@Override
public String toString()
{
return "Event [id=" + id + ", timestamp=" + timestamp + ", getId()="
+ getId() + ", hashCode()=" + hashCode() + ", getTimestamp()="
+ getTimestamp() + ", getClass()=" + getClass()
+ ", toString()=" + super.toString() + "]";
}
}
------------------------------------------------
package com.test;
import org.kie.api.definition.type.Role;
import org.kie.api.definition.type.Role.Type;
@Role(Type.EVENT)
public class RuleCheckEvent extends Event
{
private String groupId;
public RuleCheckEvent(String groupId, String id)
{
this.groupId = groupId;
this.id = id;
}
public String getGroupId()
{
return groupId;
}
public void setGroupId(String groupId)
{
this.groupId = groupId;
}
@Override
public String toString()
{
return "RuleCheckEvent [groupId=" + groupId + ", id=" + id
+ ", timestamp=" + timestamp + ", getGroupId()=" + getGroupId()
+ ", getId()=" + getId() + ", hashCode()=" + hashCode()
+ ", getTimestamp()=" + getTimestamp() + ", toString()="
+ super.toString() + ", getClass()=" + getClass() + "]";
}
@Override
public int hashCode()
{
final int prime = 31;
int result = super.hashCode();
result = prime * result + ((groupId == null) ? 0 : groupId.hashCode());
return result;
}
@Override
public boolean equals(Object obj)
{
if (this == obj)
return true;
if (!super.equals(obj))
return false;
if (getClass() != obj.getClass())
return false;
RuleCheckEvent other = (RuleCheckEvent) obj;
if (groupId == null)
{
if (other.groupId != null)
return false;
}
else if (!groupId.equals(other.groupId))
return false;
return true;
}
}
-----------------------------------------------------------------------
package com.test;
public class TimeConditionEvent extends Event
{
private int index;
private String triggerTime;
public TimeConditionEvent(String id, int index, String triggerTime,
long timestamp)
{
this.id = id;
this.index = index;
this.triggerTime = triggerTime;
this.timestamp = timestamp;
}
public int getIndex()
{
return index;
}
public void setIndex(int index)
{
this.index = index;
}
public String getTriggerTime()
{
return triggerTime;
}
public void setTriggerTime(String triggerTime)
{
this.triggerTime = triggerTime;
}
}
was:
Here is the test class:
------------------------------------------------------------------------------------------------
KieServices ks = KieServices.Factory.get();
KieFileSystem kfs = ks.newKieFileSystem();
ReleaseId releaseId = ks.newReleaseId(rulepackage, "ruleEngine",
"1.0.0-SNAPSHOT");
kfs.generateAndWritePomXML(releaseId);
KieModuleModel kModuleModel = ks.newKieModuleModel();
kModuleModel.newKieBaseModel("_" + rulepackage)
.setDefault(true)
.setEventProcessingMode(EventProcessingOption.STREAM);
kfs.writeKModuleXML(kModuleModel.toXML());
String rulePath = "src/main/resources/test/";
kfs.write(rulePath + "testRule.drl", rulescript);
KieBuilder kb = ks.newKieBuilder(kfs);
kb.buildAll();
if (kb.getResults().hasMessages(Level.ERROR))
{
System.out.println(kb.getResults());
}
KieContainer kContainer = ks.newKieContainer(releaseId);
KieSessionConfiguration ksconf = ks.newKieSessionConfiguration();
ksconf.setOption(TimedRuleExectionOption.YES);
KieBase kieBase = kContainer.getKieBase("_" + rulepackage);
KieSession session = kieBase.newKieSession(ksconf, null);
session.fireAllRules();
Thread.sleep(5000);
kfs.delete(rulePath + "testRule.drl");
kfs.write(rulePath + "testRule.drl", rulescript1);
KieBuilder kb1 = ks.newKieBuilder(kfs);
kb1.buildAll();
kContainer.updateToVersion(releaseId);
session.fireAllRules();
-----------------------------------------------------------------------
rulescript:
package com.test
import com.test.RuleCheckEvent
import com.test.TimeConditionEvent
declare RuleCheckEvent
@role(event)
end
declare TimeConditionEvent
@role(event)
@expires(60s)
end
rule "Timer_icc-rule-01-12-669c-151109035449039"
timer (int:0s 60s)
salience 9999
no-loop true
enabled true
when
then
RuleCheckEvent checkEvent = new RuleCheckEvent("a7f669c150e9da7c8a13f","icc-rule-01-12-669c-151109035449039");
insert(checkEvent);
update(checkEvent);
end
rule "Timer0_icc-rule-01-12-669c-151109035449039"
timer (cron:0 */5 * * * ?)
salience 999
no-loop true
enabled true
when
then
insert(new TimeConditionEvent("icc-rule-01-12-669c-151109035449039",0,"*/5,*,*,*,?",System.currentTimeMillis()));
end
-----------------------------------------------------------------------
rulescript1:
package com.test
import com.test.RuleCheckEvent
declare RuleCheckEvent
@role(event)
end
rule "Timer_icc-rule-01-12-669c-151109040433041"
timer (int:0s 60s)
salience 9999
no-loop true
enabled true
when
then
RuleCheckEvent checkEvent = new RuleCheckEvent("a7f669c150e9da7c8a13f","icc-rule-01-12-669c-151109040433041");
insert(checkEvent);
update(checkEvent);
end
-------------------------------------------------------
package com.test;
import org.kie.api.definition.type.Role;
import org.kie.api.definition.type.Role.Type;
@Role(Type.EVENT)
public abstract class Event
{
protected String id;
protected long timestamp;
public String getId()
{
return id;
}
public void setId(String id)
{
this.id = id;
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + ((id == null) ? 0 : id.hashCode());
result = prime * result + (int) (timestamp ^ (timestamp >>> 32));
return result;
}
@Override
public boolean equals(Object obj)
{
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Event other = (Event) obj;
if (id == null)
{
if (other.id != null)
return false;
}
else if (!id.equals(other.id))
return false;
if (timestamp != other.timestamp)
return false;
return true;
}
public long getTimestamp()
{
return timestamp;
}
public void setTimestamp(long timestamp)
{
this.timestamp = timestamp;
}
@Override
public String toString()
{
return "Event [id=" + id + ", timestamp=" + timestamp + ", getId()="
+ getId() + ", hashCode()=" + hashCode() + ", getTimestamp()="
+ getTimestamp() + ", getClass()=" + getClass()
+ ", toString()=" + super.toString() + "]";
}
}
------------------------------------------------
package com.test;
import org.kie.api.definition.type.Role;
import org.kie.api.definition.type.Role.Type;
@Role(Type.EVENT)
public class RuleCheckEvent extends Event
{
private String groupId;
public RuleCheckEvent(String groupId, String id)
{
this.groupId = groupId;
this.id = id;
}
public String getGroupId()
{
return groupId;
}
public void setGroupId(String groupId)
{
this.groupId = groupId;
}
@Override
public String toString()
{
return "RuleCheckEvent [groupId=" + groupId + ", id=" + id
+ ", timestamp=" + timestamp + ", getGroupId()=" + getGroupId()
+ ", getId()=" + getId() + ", hashCode()=" + hashCode()
+ ", getTimestamp()=" + getTimestamp() + ", toString()="
+ super.toString() + ", getClass()=" + getClass() + "]";
}
@Override
public int hashCode()
{
final int prime = 31;
int result = super.hashCode();
result = prime * result + ((groupId == null) ? 0 : groupId.hashCode());
return result;
}
@Override
public boolean equals(Object obj)
{
if (this == obj)
return true;
if (!super.equals(obj))
return false;
if (getClass() != obj.getClass())
return false;
RuleCheckEvent other = (RuleCheckEvent) obj;
if (groupId == null)
{
if (other.groupId != null)
return false;
}
else if (!groupId.equals(other.groupId))
return false;
return true;
}
}
-----------------------------------------------------------------------
package com.test;
public class TimeConditionEvent extends Event
{
private int index;
private String triggerTime;
public TimeConditionEvent(String id, int index, String triggerTime,
long timestamp)
{
this.id = id;
this.index = index;
this.triggerTime = triggerTime;
this.timestamp = timestamp;
}
public int getIndex()
{
return index;
}
public void setIndex(int index)
{
this.index = index;
}
public String getTriggerTime()
{
return triggerTime;
}
public void setTriggerTime(String triggerTime)
{
this.triggerTime = triggerTime;
}
}
> java.lang.NullPointerException at org.drools.core.reteoo.NodeTypeEnums.isBetaNode(NodeTypeEnums.java:88)
> --------------------------------------------------------------------------------------------------------
>
> Key: DROOLS-978
> URL: https://issues.jboss.org/browse/DROOLS-978
> Project: Drools
> Issue Type: Bug
> Components: core engine
> Affects Versions: 6.3.0.Final, 6.4.x
> Environment: JDK6 Win7 64bit
> Reporter: bing yang
> Assignee: Mario Fusco
> Labels: jboss
>
> when i update the stateful rule in the kfs, then it gives me the NPE:
> the 6.3.0.Final and the 6.4.0-snapshot can throws this exception:
> Exception in thread "main" java.lang.NullPointerException
> at org.drools.core.reteoo.NodeTypeEnums.isBetaNode(NodeTypeEnums.java:88)
> at org.drools.core.phreak.RuleNetworkEvaluator.innerEval(RuleNetworkEvaluator.java:254)
> at org.drools.core.phreak.RuleNetworkEvaluator.outerEval(RuleNetworkEvaluator.java:166)
> at org.drools.core.phreak.RuleNetworkEvaluator.evaluateNetwork(RuleNetworkEvaluator.java:123)
> at org.drools.core.phreak.RuleExecutor.evaluateNetwork(RuleExecutor.java:65)
> at org.drools.core.common.DefaultAgenda.evaluateEagerList(DefaultAgenda.java:1004)
> at org.drools.core.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:961)
> at org.drools.core.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1292)
> at org.drools.core.impl.StatefulKnowledgeSessionImpl.internalFireAllRules(StatefulKnowledgeSessionImpl.java:1294)
> at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1281)
> at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1260)
> at com.test.TestAA.main(TestAA.java:103)
> the TestAA.java:103 is
> 102: kContainer.updateToVersion(releaseId);
> 103: session.fireAllRules();
--
This message was sent by Atlassian JIRA
(v6.4.11#64026)
More information about the jboss-jira
mailing list