Hello
I'm sending the message once again due to problems with code samples
visibility in the previous one.
I've got following rule:
rule "enabled paramId: 1, id: 0"
salience 50
when
(def0: EmParamDefinition(paramName == "p2", listIndex == -1) and
EmParamValue(paramDefinitionId == def0, requiredValue == 1))
$param : EmParamValue(id == 1, enabled == false)
not ParentDisabled(id == 1)
then
$param.setEnabled(true);
update($param);
end
It compiles fine under Drools 5.1.1, but after switching to 5.3.0.CR1 I
get following exception:
[Error: unexpected end of statement]
[Near : {... def ....}]
^
[Line: 1, Column: 4]
at org.mvel2.compiler.AbstractParser._captureBlock(AbstractParser.java:1470)
at org.mvel2.compiler.AbstractParser.captureCodeBlock(AbstractParser.java:1446)
at org.mvel2.compiler.AbstractParser.nextToken(AbstractParser.java:421)
at org.mvel2.compiler.ExpressionCompiler._compile(ExpressionCompiler.java:128)
at org.mvel2.compiler.ExpressionCompiler.compile(ExpressionCompiler.java:62)
at org.mvel2.MVEL.analysisCompile(MVEL.java:668)
at org.mvel2.MVEL.analysisCompile(MVEL.java:672)
at org.drools.rule.builder.PatternBuilder.setInputs(PatternBuilder.java:854)
at org.drools.rule.builder.PatternBuilder.build(PatternBuilder.java:595)
at
org.drools.rule.builder.PatternBuilder.processConstraintsAndBinds(PatternBuilder.java:397)
at org.drools.rule.builder.PatternBuilder.build(PatternBuilder.java:309)
at org.drools.rule.builder.PatternBuilder.build(PatternBuilder.java:132)
at org.drools.rule.builder.GroupElementBuilder.build(GroupElementBuilder.java:65)
at org.drools.rule.builder.RuleBuilder.build(RuleBuilder.java:80)
at org.drools.compiler.PackageBuilder.addRule(PackageBuilder.java:2241)
at org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:802)
at org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:388)
at org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:566)
at org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:35)
at
com.proximetry.elmgr.services.DependenciesBean$Expander.addDrl(DependenciesBean.java:110)
It is
(def0: EmParamDefinition(paramName == "p2", listIndex == -1) and
EmParamValue(paramDefinitionId == def0, requiredValue == 1))
line that causes the problem - the exeption disappears after removing
it. What's interesting, when I add '$' sign to binding variable name,
and the line looks like:
($def0: EmParamDefinition(paramName == "p2", listIndex == -1) and
EmParamValue(paramDefinitionId == $def0, requiredValue == 1))
instead of the exception I get DRL error:
[DialectError message='Unable to wire compiled classes, probably related to
compilation failures:sun.reflect.generics.reflectiveObjects.WildcardTypeImpl cannot be
cast to java.lang.Class']
For completness, this is how I add DRL resources:
public void addDrl(Reader rdr) {
KnowledgeBuilder kBuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kBuilder.add( ResourceFactory.newReaderResource(rdr), ResourceType.DRL);
if( kBuilder.hasErrors() ){
for( KnowledgeBuilderError err: kBuilder.getErrors() ){
StackTrace.error(this, err);
}
throw new IllegalStateException( "DRL errors" );
}
knowledgeBase.addKnowledgePackages( kBuilder.getKnowledgePackages() );
}
I would be grateful if someone has an idea, why after switching Drools
version such problem exists.