]
Yingzhi Wang updated JBRULES-3709:
----------------------------------
Attachment: user_src.zip
The source of the issue
When use method of FACT match(Object... objs), throws
java.lang.RuntimeException: cannot invoke method
-------------------------------------------------------------------------------------------------------
Key: JBRULES-3709
URL:
https://issues.jboss.org/browse/JBRULES-3709
Project: JBRULES
Issue Type: Bug
Security Level: Public(Everyone can see)
Components: drools-core
Affects Versions: 5.4.0.Final, 5.5.0.Final
Environment: OS: Windows xp
IDE: Eclipse
JRE: 1.6
Reporter: Yingzhi Wang
Assignee: Mark Proctor
Priority: Critical
Labels: RuntimeException, invoke, method
Attachments: user_src.zip
I writed a method of fact User "public boolean match(Boolean... bs)", and
when I use it in drl like this "User(match(true, true))", it will thows
exception: java.lang.RuntimeException: cannot invoke method: match. But if I change it to
User(match(true)), it will be ok.
And also, If I insert fact first, then add the rule, It will throws this exception, if I
add the rule first, then insert fact, it will be ok.
Is DRools not support method(Object... objs)?
FACT: User
package user;
public class User {
public boolean match(Boolean... bs) {
return true;
}
public boolean matchList(Boolean b1, Boolean b2) {
return true;
}
}
DRL: user.drl
package test
import user.User
rule "test"
when
// User(match(true)) // is ok
User(match(true, true)) // is err
// User(matchList(true, true)) // is ok
then
System.out.println("It's OK!");
end
main:
KnowledgeBase base = KnowledgeBaseFactory.newKnowledgeBase();
StatefulKnowledgeSession s = base.newStatefulKnowledgeSession();
// user insert here will be err
User user = new User();
s.insert(user);
// add rule
KnowledgeBuilder builder = KnowledgeBuilderFactory.newKnowledgeBuilder();
builder.add(ResourceFactory.newClassPathResource("user.drl", Test.class),
ResourceType.DRL);
KnowledgeBuilderErrors errs = builder.getErrors();
if (!errs.isEmpty()) {
for (KnowledgeBuilderError e: errs) {
System.out.println(e.toString());
}
}
Collection<KnowledgePackage> col = builder.getKnowledgePackages();
base.addKnowledgePackages(col);
// user insert here is ok
// User user = new User();
// s.insert(user);
// fire
s.fireAllRules();
Exception:
Exception in thread "main" java.lang.RuntimeException: cannot invoke method:
match
at org.mvel2.optimizers.impl.refl.nodes.MethodAccessor.getValue(MethodAccessor.java:63)
at org.mvel2.ast.ASTNode.getReducedValueAccelerated(ASTNode.java:108)
at org.mvel2.MVELRuntime.execute(MVELRuntime.java:85)
at org.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:123)
at org.mvel2.MVEL.executeExpression(MVEL.java:930)
at
org.drools.rule.constraint.MvelConditionEvaluator.evaluate(MvelConditionEvaluator.java:70)
at
org.drools.rule.constraint.MvelConditionEvaluator.evaluate(MvelConditionEvaluator.java:49)
at org.drools.rule.constraint.MvelConstraint.evaluate(MvelConstraint.java:167)
at org.drools.rule.constraint.MvelConstraint.isAllowed(MvelConstraint.java:124)
at org.drools.reteoo.AlphaNode$ObjectSinkUpdateAdapter.assertObject(AlphaNode.java:325)
at org.drools.reteoo.ObjectTypeNode.updateSink(ObjectTypeNode.java:334)
at org.drools.reteoo.AlphaNode.updateSink(AlphaNode.java:203)
at org.drools.reteoo.LeftInputAdapterNode.attach(LeftInputAdapterNode.java:120)
at org.drools.reteoo.builder.BuildUtils.attachNode(BuildUtils.java:145)
at
org.drools.reteoo.builder.GroupElementBuilder$AndBuilder.build(GroupElementBuilder.java:127)
at org.drools.reteoo.builder.GroupElementBuilder.build(GroupElementBuilder.java:71)
at org.drools.reteoo.builder.ReteooRuleBuilder.addSubRule(ReteooRuleBuilder.java:155)
at org.drools.reteoo.builder.ReteooRuleBuilder.addRule(ReteooRuleBuilder.java:128)
at org.drools.reteoo.ReteooBuilder.addRule(ReteooBuilder.java:116)
at org.drools.reteoo.ReteooRuleBase.addRule(ReteooRuleBase.java:445)
at org.drools.common.AbstractRuleBase.addRule(AbstractRuleBase.java:956)
at org.drools.common.AbstractRuleBase.addPackages(AbstractRuleBase.java:627)
at org.drools.reteoo.ReteooRuleBase.addPackages(ReteooRuleBase.java:472)
at org.drools.impl.KnowledgeBaseImpl.addKnowledgePackages(KnowledgeBaseImpl.java:150)
at user.Test.main(Test.java:36)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 2
at
org.mvel2.optimizers.impl.refl.nodes.MethodAccessor.executeAll(MethodAccessor.java:149)
at org.mvel2.optimizers.impl.refl.nodes.MethodAccessor.getValue(MethodAccessor.java:48)
... 24 more
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: