[
https://issues.jboss.org/browse/DROOLS-773?page=com.atlassian.jira.plugin...
]
Hanbing Luo updated DROOLS-773:
-------------------------------
Steps to Reproduce:
How to reproduce
1) Create a test model say TestModelChangeObj and create a field say field_1. Create a
test rule say test_model_change.drl and new a TestModelChangeObj in action and set field_1
for this object. To help identify which version of rule is used/fired you can print some
debug info.
when
// your condition
then
TestModelChangeObj testObj=new TestModelChangeObj();
testObj.setField_1("test_field_1");
System.out.println("setField_1 finished");
2) Build and release your package using 0.0.1-SNAPSHOT
3) Write client code to use kie server released jars. Create some inputs to make sure
test_model_change is fired. When JVM first load everything works fine.
Code snippet
this.ks = KieServices.Factory.get();
this.kbaseConf = ks.newKieBaseConfiguration();
this.releaseId = ks.newReleaseId(GROUP_ID, lowerPkgName, VERSION_EXP);
this.container = ks.newKieContainer(releaseId);
kScanner = ks.newKieScanner(container);
// Start the KieScanner polling the Maven repository
kScanner.start(interval * 1000);
kScanner.scanNow();
kbase = container.newKieBase(kbaseConf);
KieSession kieSession = kbase.newKieSession();
// prepare inputs ...
kieSession.fireAllRules(new MyFilter());
4) Set a debug point to pause some time which make sue use same JVM. In kie GUI create a
new field say field_2 and change test_model_change.drl to set field_2 for
TestModelChangeObj in action.
5) Build and release this change and let JVM incrementally load new jar. Create same
inputs then you will see this bug. This bug has different behavior for "mvel"
and "java" dialect in test_model_change.drl.
a) Mvel dialect: Throw error when call container.newKieBase(kbaseConf);
[Error: unable to resolve method using strict-mode:
com.yourcompany.TestModelChangeObj.setField_2(java.lang.String)]
[Near : {... testObj.setField_2("test_field_2"); ....}]
^
[Line: 3, Column: 10]
at org.mvel2.compiler.PropertyVerifier.getMethod(PropertyVerifier.java:577)
at org.mvel2.compiler.PropertyVerifier.analyze(PropertyVerifier.java:120)
at org.mvel2.compiler.ExpressionCompiler.verify(ExpressionCompiler.java:384)
at org.mvel2.compiler.ExpressionCompiler._compile(ExpressionCompiler.java:277)
at org.mvel2.compiler.ExpressionCompiler.compile(ExpressionCompiler.java:63)
at org.mvel2.MVEL.compileExpression(MVEL.java:810)
at org.drools.core.base.mvel.MVELCompilationUnit.compile(MVELCompilationUnit.java:433)
at
org.drools.core.base.mvel.MVELCompilationUnit.getCompiledExpression(MVELCompilationUnit.java:244)
at
org.drools.core.base.mvel.MVELCompilationUnit.getCompiledExpression(MVELCompilationUnit.java:205)
at org.drools.core.base.mvel.MVELConsequence.compile(MVELConsequence.java:81)
at
org.drools.core.rule.MVELDialectRuntimeData.onBeforeExecute(MVELDialectRuntimeData.java:173)
at
org.drools.core.rule.DialectRuntimeRegistry.onBeforeExecute(DialectRuntimeRegistry.java:144)
at org.drools.core.impl.KnowledgeBaseImpl.addPackages(KnowledgeBaseImpl.java:817)
at
org.drools.core.impl.KnowledgeBaseImpl.addKnowledgePackages(KnowledgeBaseImpl.java:272)
at
org.drools.compiler.kie.builder.impl.KieContainerImpl.createKieBase(KieContainerImpl.java:455)
at
org.drools.compiler.kie.builder.impl.KieContainerImpl.newKieBase(KieContainerImpl.java:414)
at
org.drools.compiler.kie.builder.impl.KieContainerImpl.newKieBase(KieContainerImpl.java:409)
b) Java dialect: throw NoSuchMethodError when call kieSession.fireAllRules(new
MyFilter());
KieBase newKbase=container.newKieBase(kbaseConf);
KieSession kieSession = newKbase.newKieSession();
// prepare inputs ...
kieSession.fireAllRules(new MyFilter());
java.lang.NoSuchMethodError:
com.yourcompany.TestModelChangeObj.setField_2(Ljava/lang/String)
was:
How to reproduce
1) Create a test model say TestModelChangeObj and create a field say field_1. Create a
test rule say test_model_change.drl and new a TestModelChangeObj in action and set field_1
for this object. To help identify which version of rule is used/fired you can print some
debug info.
when
// your condition
then
TestModelChangeObj testObj=new TestModelChangeObj();
testObj.setField_1("test_field_1");
System.out.println("setField_1 finished");
2) Build and release your package using 0.0.1-SNAPSHOT
3) Write client code to use kie server released jars. Create some inputs to make sure
test_model_change is fired. When JVM first load everything works fine.
Code snippet
this.ks = KieServices.Factory.get();
this.kbaseConf = ks.newKieBaseConfiguration();
this.releaseId = ks.newReleaseId(GROUP_ID, lowerPkgName, VERSION_EXP);
this.container = ks.newKieContainer(releaseId);
kScanner = ks.newKieScanner(container);
// Start the KieScanner polling the Maven repository
kScanner.start(interval * 1000);
kScanner.scanNow();
kbase = container.newKieBase(kbaseConf);
KieSession kieSession = kbase.newKieSession();
// prepare inputs ...
kieSession.fireAllRules(new MyFilter());
4) Set a debug point to pause some time which make sue use same JVM. In kie GUI create a
new field say field_2 and change test_model_change.drl to set field_2 for
TestModelChangeObj in action.
5) Build and release this change and let JVM incrementally load new jar. Create same
inputs then you will see this bug. This bug has different behavior for "mvel"
and "java" dialect in test_model_change.drl.
a) Mvel dialect: Throw error when call container.newKieBase(kbaseConf);
[Error: unable to resolve method using strict-mode:
com.yourcompany.TestModelChangeObj.setField_2(java.lang.String)]
[Near : {... testObj.setField_2("test_field_2"); ....}]
^
[Line: 3, Column: 10]
at org.mvel2.compiler.PropertyVerifier.getMethod(PropertyVerifier.java:577)
at org.mvel2.compiler.PropertyVerifier.analyze(PropertyVerifier.java:120)
at org.mvel2.compiler.ExpressionCompiler.verify(ExpressionCompiler.java:384)
at org.mvel2.compiler.ExpressionCompiler._compile(ExpressionCompiler.java:277)
at org.mvel2.compiler.ExpressionCompiler.compile(ExpressionCompiler.java:63)
at org.mvel2.MVEL.compileExpression(MVEL.java:810)
at org.drools.core.base.mvel.MVELCompilationUnit.compile(MVELCompilationUnit.java:433)
at
org.drools.core.base.mvel.MVELCompilationUnit.getCompiledExpression(MVELCompilationUnit.java:244)
at
org.drools.core.base.mvel.MVELCompilationUnit.getCompiledExpression(MVELCompilationUnit.java:205)
at org.drools.core.base.mvel.MVELConsequence.compile(MVELConsequence.java:81)
at
org.drools.core.rule.MVELDialectRuntimeData.onBeforeExecute(MVELDialectRuntimeData.java:173)
at
org.drools.core.rule.DialectRuntimeRegistry.onBeforeExecute(DialectRuntimeRegistry.java:144)
at org.drools.core.impl.KnowledgeBaseImpl.addPackages(KnowledgeBaseImpl.java:817)
at
org.drools.core.impl.KnowledgeBaseImpl.addKnowledgePackages(KnowledgeBaseImpl.java:272)
at
org.drools.compiler.kie.builder.impl.KieContainerImpl.createKieBase(KieContainerImpl.java:455)
at
org.drools.compiler.kie.builder.impl.KieContainerImpl.newKieBase(KieContainerImpl.java:414)
at
org.drools.compiler.kie.builder.impl.KieContainerImpl.newKieBase(KieContainerImpl.java:409)
b) Java dialect: throw NoSuchMethodError when call kieSession.fireAllRules(new
MyFilter());
KieBase newKbase=container.newKieBase(kbaseConf);
KieSession kieSession = newKbase.newKieSession();
// prepare inputs ...
kieSession.fireAllRules(new MyFilter());
java.lang.NoSuchMethodError:
com.yourcompany.TestModelChangeObj.setField_2(Ljava/lang/String;)
Can't load correct model class info when incrementally load kie
jar
-------------------------------------------------------------------
Key: DROOLS-773
URL:
https://issues.jboss.org/browse/DROOLS-773
Project: Drools
Issue Type: Bug
Affects Versions: 6.2.0.Final
Environment: drools version: 6.2.0.Final
-bash-4.1$ java -version
java version "1.7.0_76"
Java(TM) SE Runtime Environment (build 1.7.0_76-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.76-b04, mixed mode)
-bash-4.1$ lsb_release -a
LSB
Version: :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID: CentOS
Description: CentOS release 6.6 (Final)
Release: 6.6
Codename: Final
Reporter: Hanbing Luo
Assignee: Mark Proctor
Can't load correct model class info when incrementally load kie jar. New created
field/method in model class can't be used in rule although rule compile successfully
in kie GUI.
I also did some investigation and looks like changed model class info is not correct in
getTypeDeclarations.
if (kiePackage instanceof InternalKnowledgePackage) {
InternalKnowledgePackage ikp = (InternalKnowledgePackage) kiePackage;
Map<String,TypeDeclaration> modelsMap = ikp.getTypeDeclarations();
}
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)