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@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users