[rules-users] Janino Autoboxing inside drools

Mark Proctor mproctor at codehaus.org
Thu Apr 10 14:46:15 EDT 2008


Janno has no configurations as such, so it should work. If it doesn't 
work I'm guessing it's a bug with Janino. You could probably recreate 
the issue outside of Drools and submit a bug to the Janino author.

Mark
Joe White wrote:
>
> According to the Janino Jira in 
> http://jira.codehaus.org/browse/JANINO-72 autoboxing was supported in 
> version 2.5.6. It looks like drools 4.0.4 uses Janino 2.5.10. The test 
> below uses a DRL file that would require autoboxing and it produces a 
> runtime exception from Janino. Does anybody know of a way to make a 
> Janino/Drools Autoboxing combination work? I have to use autoboxing 
> and I would very much prefer to use Janino over MVEL for drl compilation.
>
>  
>
>  
>
> Thanks for your help,
>
>  
>
> Joe
>
>  
>
> The information below includes the stack trace, the Input java file, 
> the DRL, and a snippet for the drools setup and execution. The 
> exception is easy to produce and the info below should be enough to 
> reproduce it.
>
>  
>
>  
>
> /********************INPUT JAVA OBJECT *******************************/
>
> *package* com.sample;
>
>  
>
> *public* *class* Input {
>
>       *public* Double valOne;
>
>       *public* Double valTwo;
>
>      
>
>       *public* Double getValOne() {
>
>             *return* valOne;
>
>       }
>
>       *public* *void* setValOne(Double valOne) {
>
>             *this*.valOne = valOne;
>
>       }
>
>       *public* Double getValTwo() {
>
>             *return* valTwo;
>
>       }
>
>       *public* *void* setValTwo(Double valTwo) {
>
>             *this*.valTwo = valTwo;
>
>       }
>
> }
>
>  
>
> /********************END *******************************/
>
>  
>
>  
>
>  
>
> /********************DRL *******************************/
>
> *package* test;
>
> *import* com.sample.Input
>
> *dialect* "java"
>
> *rule* "test 293"
>
>     *when*
>
>         inputVal : Input()
>
>     *then*
>
>         //double valOne = 0;
>
>         *double* deductibleapplied =inputVal.valOne*inputVal.valTwo;
>
> *end*
>
> /********************END *******************************/
>
>  
>
>  
>
> /********************DROOLS SETUP *******************************/
>
> ...
>
> PackageBuilderConfiguration pkgBuilderCfg = *new* 
> PackageBuilderConfiguration();
>
> JavaDialectConfiguration javaConf = (JavaDialectConfiguration) 
> pkgBuilderCfg.getDialectConfiguration( "java" );
>
> javaConf.setCompiler( JavaDialectConfiguration./JANINO/ );                
>
> PackageBuilder builder = *new* PackageBuilder(pkgBuilderCfg);
>
>  
>
> ...
>
>  
>
> Input input = *new* Input();
>
> input.setValOne(10.0);
>
> input.setValTwo(1000.0);
>
> workingMemory.insert( input );
>
> workingMemory.fireAllRules();  
>
> /********************END *******************************/
>
>  
>
> /******************** STACK TRACE *******************************/
>
> _java.lang.RuntimeException_: SNO: Conversion failed
>
>       at 
> org.codehaus.janino.UnitCompiler.binaryNumericPromotion(UnitCompiler.java)
>
>       at 
> org.codehaus.janino.UnitCompiler.compileArithmeticOperation(UnitCompiler.java)
>
>       at org.codehaus.janino.UnitCompiler.compileGet2(UnitCompiler.java)
>
>       at org.codehaus.janino.UnitCompiler.access$39(UnitCompiler.java)
>
>       at 
> org.codehaus.janino.UnitCompiler$7.visitBinaryOperation(UnitCompiler.java)
>
>       at org.codehaus.janino.Java$BinaryOperation.accept(Java.java)
>
>       at org.codehaus.janino.UnitCompiler.compileGet(UnitCompiler.java)
>
>       at 
> org.codehaus.janino.UnitCompiler.compileGetValue(UnitCompiler.java)
>
>       at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java)
>
>       at org.codehaus.janino.UnitCompiler.access$12(UnitCompiler.java)
>
>       at 
> org.codehaus.janino.UnitCompiler$2.visitLocalVariableDeclarationStatement(UnitCompiler.java)
>
>       at 
> org.codehaus.janino.Java$LocalVariableDeclarationStatement.accept(Java.java)
>
>       at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java)
>
>       at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java)
>
>       at org.codehaus.janino.UnitCompiler.access$3(UnitCompiler.java)
>
>       at org.codehaus.janino.UnitCompiler$2.visitBlock(UnitCompiler.java)
>
>       at org.codehaus.janino.Java$Block.accept(Java.java)
>
>       at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java)
>
>       at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java)
>
>       at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java)
>
>       at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java)
>
>       at 
> org.codehaus.janino.UnitCompiler$1.visitPackageMemberClassDeclaration(UnitCompiler.java)
>
>       at 
> org.codehaus.janino.Java$PackageMemberClassDeclaration.accept(Java.java)
>
>       at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java)
>
>       at org.codehaus.janino.UnitCompiler.compileUnit(UnitCompiler.java)
>
>       at org.codehaus.janino.Compiler.compile(Compiler.java)
>
>       at 
> org.drools.commons.jci.compilers.JaninoJavaCompiler.compile(_JaninoJavaCompiler.java:174_)
>
>       at 
> org.drools.commons.jci.compilers.AbstractJavaCompiler.compile(_AbstractJavaCompiler.java:51_)
>
>       at 
> org.drools.rule.builder.dialect.java.JavaDialect.compileAll(_JavaDialect.java:332_)
>
>       at 
> org.drools.compiler.DialectRegistry.compileAll(_DialectRegistry.java:60_)
>
>       at 
> org.drools.compiler.PackageBuilder.addPackage(_PackageBuilder.java:308_)
>
>       at 
> org.drools.compiler.PackageBuilder.addPackageFromDrl(_PackageBuilder.java:167_)
>
>       at com.sample.SimpleTester.readRule(_SimpleTester.java:62_)
>
>       at com.sample.SimpleTester.main(_SimpleTester.java:23_)
>
>  
>
>  
>
>  
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>   

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20080410/0747bd6e/attachment.html 


More information about the rules-users mailing list