-
Bug
-
Resolution: Done
-
Major
-
7.12.1.GA
When exec-model builds a rule like this:
global List results; dialect "mvel" rule R when $l : List() from accumulate (Person($addrList : addresses), init( List<String> cityList = new ArrayList(); ), action( for(Address addr: $addrList){String city = addr.getCity(); cityList.add(city);} ), result( cityList ) ) then results.add($l); end
fails with
org.drools.mvelcompiler.MvelCompilerException: java.lang.ClassNotFoundException: Unable to find class 'List<String>' at org.drools.mvelcompiler.context.MvelCompilerContext.resolveType(MvelCompilerContext.java:83) at org.drools.mvelcompiler.LHSPhase.getRHSorLHSType(LHSPhase.java:372) at org.drools.mvelcompiler.LHSPhase.visit(LHSPhase.java:284) at org.drools.mvelcompiler.LHSPhase.visit(LHSPhase.java:1) at com.github.javaparser.ast.body.VariableDeclarator.accept(VariableDeclarator.java:143) at org.drools.mvelcompiler.LHSPhase.visit(LHSPhase.java:276) at org.drools.mvelcompiler.LHSPhase.visit(LHSPhase.java:1) at com.github.javaparser.ast.expr.VariableDeclarationExpr.accept(VariableDeclarationExpr.java:112) at org.drools.mvelcompiler.LHSPhase.visit(LHSPhase.java:295) at org.drools.mvelcompiler.LHSPhase.visit(LHSPhase.java:1) at com.github.javaparser.ast.stmt.ExpressionStmt.accept(ExpressionStmt.java:71) at org.drools.mvelcompiler.LHSPhase.invoke(LHSPhase.java:95) at org.drools.mvelcompiler.StatementVisitor.compileMVEL(StatementVisitor.java:68) at org.drools.mvelcompiler.StatementVisitor.visit(StatementVisitor.java:63) at org.drools.mvelcompiler.StatementVisitor.visit(StatementVisitor.java:1) at com.github.javaparser.ast.stmt.ExpressionStmt.accept(ExpressionStmt.java:71) at org.drools.mvelcompiler.StatementVisitor.lambda$5(StatementVisitor.java:107) at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195) at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1654) at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913) at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578) at org.drools.mvelcompiler.StatementVisitor.visit(StatementVisitor.java:108) at org.drools.mvelcompiler.StatementVisitor.visit(StatementVisitor.java:1) at com.github.javaparser.ast.stmt.BlockStmt.accept(BlockStmt.java:70) at org.drools.mvelcompiler.MvelCompiler.compileStatement(MvelCompiler.java:68) at org.drools.modelcompiler.builder.generator.visitor.accumulate.AccumulateInline.parseInitBlock(AccumulateInline.java:186) at org.drools.modelcompiler.builder.generator.visitor.accumulate.AccumulateInline.visitAccInlineCustomCode(AccumulateInline.java:117) at org.drools.modelcompiler.builder.generator.visitor.accumulate.AccumulateInlineVisitor.inlineAccumulate(AccumulateInlineVisitor.java:57) at org.drools.modelcompiler.builder.generator.visitor.accumulate.AccumulateVisitor.visit(AccumulateVisitor.java:128) at org.drools.modelcompiler.builder.generator.visitor.ModelGeneratorVisitor.visit(ModelGeneratorVisitor.java:125) at org.drools.compiler.lang.descr.PatternDescr.accept(PatternDescr.java:303) at org.drools.modelcompiler.builder.generator.visitor.AndVisitor.visit(AndVisitor.java:51) at org.drools.modelcompiler.builder.generator.visitor.ModelGeneratorVisitor.visit(ModelGeneratorVisitor.java:69) at org.drools.modelcompiler.builder.generator.ModelGenerator.processRule(ModelGenerator.java:200) at org.drools.modelcompiler.builder.generator.ModelGenerator.processRuleDescr(ModelGenerator.java:176) at org.drools.modelcompiler.builder.generator.ModelGenerator.generateModel(ModelGenerator.java:165) at org.drools.modelcompiler.builder.ModelBuilderImpl.compileKnowledgePackages(ModelBuilderImpl.java:287) at org.drools.modelcompiler.builder.ModelBuilderImpl.buildRules(ModelBuilderImpl.java:222) at org.drools.modelcompiler.builder.ModelBuilderImpl.doSecondBuildStep(ModelBuilderImpl.java:119) at org.drools.compiler.builder.impl.CompositeKnowledgeBuilderImpl.build(CompositeKnowledgeBuilderImpl.java:115) at org.drools.compiler.builder.impl.CompositeKnowledgeBuilderImpl.build(CompositeKnowledgeBuilderImpl.java:99) at org.drools.compiler.kie.builder.impl.AbstractKieProject.buildKnowledgePackages(AbstractKieProject.java:270) at org.drools.compiler.kie.builder.impl.AbstractKieProject.buildKnowledgePackages(AbstractKieProject.java:216) at org.drools.compiler.kie.builder.impl.AbstractKieProject.verify(AbstractKieProject.java:80) at org.drools.compiler.kie.builder.impl.KieBuilderImpl.buildKieProject(KieBuilderImpl.java:277) at org.drools.compiler.kie.builder.impl.KieBuilderImpl.buildAll(KieBuilderImpl.java:245) at org.drools.compiler.kie.builder.impl.KieBuilderImpl.buildAll(KieBuilderImpl.java:202) at org.drools.modelcompiler.BaseModelTest.createKieBuilder(BaseModelTest.java:147) at org.drools.modelcompiler.BaseModelTest.createKieBuilder(BaseModelTest.java:130) at org.drools.modelcompiler.BaseModelTest.getKieContainer(BaseModelTest.java:119) at org.drools.modelcompiler.BaseModelTest.getKieContainer(BaseModelTest.java:112) at org.drools.modelcompiler.BaseModelTest.getKieSession(BaseModelTest.java:108) at org.drools.modelcompiler.BaseModelTest.getKieSession(BaseModelTest.java:104) at org.drools.modelcompiler.GenericsTest.testGenericsAccumulateInlineCode(GenericsTest.java:99) ... Caused by: java.lang.ClassNotFoundException: Unable to find class 'List<String>' at org.drools.core.addon.ClassTypeResolver.resolveType(ClassTypeResolver.java:268) at org.drools.core.addon.ClassTypeResolver.resolveType(ClassTypeResolver.java:153) at org.drools.mvelcompiler.context.MvelCompilerContext.resolveType(MvelCompilerContext.java:81) ... 90 more
Actually, the above rule contains one more issue. If we solve the generics issue, we will hit another Exception:
java.lang.ClassCastException: class com.github.javaparser.printer.DefaultPrettyPrinterVisitor cannot be cast to class org.drools.mvel.parser.ast.visitor.DrlVoidVisitor (com.github.javaparser.printer.DefaultPrettyPrinterVisitor and org.drools.mvel.parser.ast.visitor.DrlVoidVisitor are in unnamed module of loader 'app') at org.drools.mvel.parser.ast.expr.DrlNameExpr.accept(DrlNameExpr.java:86) at com.github.javaparser.printer.DefaultPrettyPrinterVisitor.lambda$visit$8(DefaultPrettyPrinterVisitor.java:1031) at java.base/java.util.Optional.ifPresent(Optional.java:183) at com.github.javaparser.printer.DefaultPrettyPrinterVisitor.visit(DefaultPrettyPrinterVisitor.java:1030) at com.github.javaparser.printer.DefaultPrettyPrinterVisitor.visit(DefaultPrettyPrinterVisitor.java:163) at com.github.javaparser.ast.expr.MethodCallExpr.accept(MethodCallExpr.java:122) at com.github.javaparser.printer.DefaultPrettyPrinterVisitor.visit(DefaultPrettyPrinterVisitor.java:838) at com.github.javaparser.printer.DefaultPrettyPrinterVisitor.visit(DefaultPrettyPrinterVisitor.java:163) at com.github.javaparser.ast.expr.EnclosedExpr.accept(EnclosedExpr.java:75) at com.github.javaparser.printer.DefaultPrettyPrinterVisitor.visit(DefaultPrettyPrinterVisitor.java:811) at com.github.javaparser.printer.DefaultPrettyPrinterVisitor.visit(DefaultPrettyPrinterVisitor.java:163) at com.github.javaparser.ast.expr.CastExpr.accept(CastExpr.java:81) at com.github.javaparser.printer.DefaultPrettyPrinterVisitor.visit(DefaultPrettyPrinterVisitor.java:697) at com.github.javaparser.printer.DefaultPrettyPrinterVisitor.visit(DefaultPrettyPrinterVisitor.java:163) at com.github.javaparser.ast.body.VariableDeclarator.accept(VariableDeclarator.java:149) at com.github.javaparser.printer.DefaultPrettyPrinterVisitor.visit(DefaultPrettyPrinterVisitor.java:1290) at com.github.javaparser.printer.DefaultPrettyPrinterVisitor.visit(DefaultPrettyPrinterVisitor.java:163) at com.github.javaparser.ast.expr.VariableDeclarationExpr.accept(VariableDeclarationExpr.java:118) at com.github.javaparser.printer.DefaultPrettyPrinterVisitor.visit(DefaultPrettyPrinterVisitor.java:1361) at com.github.javaparser.printer.DefaultPrettyPrinterVisitor.visit(DefaultPrettyPrinterVisitor.java:163) at com.github.javaparser.ast.stmt.ExpressionStmt.accept(ExpressionStmt.java:77) at com.github.javaparser.printer.DefaultPrettyPrinterVisitor.visit(DefaultPrettyPrinterVisitor.java:1332) at com.github.javaparser.printer.DefaultPrettyPrinterVisitor.visit(DefaultPrettyPrinterVisitor.java:163) at com.github.javaparser.ast.stmt.BlockStmt.accept(BlockStmt.java:76) at com.github.javaparser.printer.DefaultPrettyPrinterVisitor.visit(DefaultPrettyPrinterVisitor.java:1332) at com.github.javaparser.printer.DefaultPrettyPrinterVisitor.visit(DefaultPrettyPrinterVisitor.java:163) at com.github.javaparser.ast.stmt.BlockStmt.accept(BlockStmt.java:76) at com.github.javaparser.printer.DefaultPrettyPrinterVisitor.visit(DefaultPrettyPrinterVisitor.java:1612) at com.github.javaparser.printer.DefaultPrettyPrinterVisitor.visit(DefaultPrettyPrinterVisitor.java:163) at com.github.javaparser.ast.stmt.ForEachStmt.accept(ForEachStmt.java:92) at com.github.javaparser.printer.DefaultPrettyPrinterVisitor.visit(DefaultPrettyPrinterVisitor.java:1332) at com.github.javaparser.printer.DefaultPrettyPrinterVisitor.visit(DefaultPrettyPrinterVisitor.java:163) at com.github.javaparser.ast.stmt.BlockStmt.accept(BlockStmt.java:76) at com.github.javaparser.printer.DefaultPrettyPrinterVisitor.visit(DefaultPrettyPrinterVisitor.java:1222) at com.github.javaparser.printer.DefaultPrettyPrinterVisitor.visit(DefaultPrettyPrinterVisitor.java:163) at com.github.javaparser.ast.body.MethodDeclaration.accept(MethodDeclaration.java:104) at com.github.javaparser.printer.DefaultPrettyPrinterVisitor.printMembers(DefaultPrettyPrinterVisitor.java:190) at com.github.javaparser.printer.DefaultPrettyPrinterVisitor.visit(DefaultPrettyPrinterVisitor.java:421) at com.github.javaparser.printer.DefaultPrettyPrinterVisitor.visit(DefaultPrettyPrinterVisitor.java:163) at com.github.javaparser.ast.body.ClassOrInterfaceDeclaration.accept(ClassOrInterfaceDeclaration.java:98) at com.github.javaparser.printer.DefaultPrettyPrinterVisitor.visit(DefaultPrettyPrinterVisitor.java:325) at com.github.javaparser.printer.DefaultPrettyPrinterVisitor.visit(DefaultPrettyPrinterVisitor.java:163) at com.github.javaparser.ast.CompilationUnit.accept(CompilationUnit.java:133) at com.github.javaparser.printer.DefaultPrettyPrinter.print(DefaultPrettyPrinter.java:104) at org.drools.modelcompiler.builder.JavaParserCompiler.toPojoSource(JavaParserCompiler.java:148) at org.drools.modelcompiler.builder.DeclaredTypeWriter.getSource(DeclaredTypeWriter.java:35) at org.drools.modelcompiler.builder.PackageSources.dumpSources(PackageSources.java:45) at org.drools.modelcompiler.builder.ModelBuilderImpl.buildRules(ModelBuilderImpl.java:228) at org.drools.modelcompiler.builder.ModelBuilderImpl.doSecondBuildStep(ModelBuilderImpl.java:119) at org.drools.compiler.builder.impl.CompositeKnowledgeBuilderImpl.build(CompositeKnowledgeBuilderImpl.java:115) at org.drools.compiler.builder.impl.CompositeKnowledgeBuilderImpl.build(CompositeKnowledgeBuilderImpl.java:99) at org.drools.compiler.kie.builder.impl.AbstractKieProject.buildKnowledgePackages(AbstractKieProject.java:270) at org.drools.compiler.kie.builder.impl.AbstractKieProject.buildKnowledgePackages(AbstractKieProject.java:216) at org.drools.compiler.kie.builder.impl.AbstractKieProject.verify(AbstractKieProject.java:80) at org.drools.compiler.kie.builder.impl.KieBuilderImpl.buildKieProject(KieBuilderImpl.java:277) at org.drools.compiler.kie.builder.impl.KieBuilderImpl.buildAll(KieBuilderImpl.java:245) at org.drools.compiler.kie.builder.impl.KieBuilderImpl.buildAll(KieBuilderImpl.java:202) at org.drools.modelcompiler.BaseModelTest.createKieBuilder(BaseModelTest.java:146) at org.drools.modelcompiler.BaseModelTest.createKieBuilder(BaseModelTest.java:129) at org.drools.modelcompiler.BaseModelTest.getKieContainer(BaseModelTest.java:118) at org.drools.modelcompiler.BaseModelTest.getKieContainer(BaseModelTest.java:111) at org.drools.modelcompiler.BaseModelTest.getKieSession(BaseModelTest.java:107) at org.drools.modelcompiler.BaseModelTest.getKieSession(BaseModelTest.java:103) at org.drools.modelcompiler.GenericsTest.testGenericsAccumulateInlineCode(GenericsTest.java:154)
- clones
-
DROOLS-7062 ClassNotFoundException when using generics in accumulate inline code
- Resolved