[rules-users] Janino Autoboxing inside drools

Joe White Joe.White at recondotech.com
Thu Apr 10 19:28:08 EDT 2008


Thanks for the quick reply. In my attempts to reproduce the issue
outside of Drools I have found that the issue was caused by an antique
version of Janino hiding in a library in an imported eclipse project.
After upgrading to the newer version of Janino things appear to be
working.

 

Thanks for your help,

Joe

 

From: rules-users-bounces at lists.jboss.org
[mailto:rules-users-bounces at lists.jboss.org] On Behalf Of Mark Proctor
Sent: Thursday, April 10, 2008 12:46 PM
To: Rules Users List
Subject: Re: [rules-users] Janino Autoboxing inside drools

 

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.jav
a)

      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.jav
a)

      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.visitLocalVariableDeclarationStatemen
t(UnitCompiler.java)

      at
org.codehaus.janino.Java$LocalVariableDeclarationStatement.accept(Java.j
ava)

      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(Un
itCompiler.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(JaninoJavaCo
mpiler.java:174)

      at
org.drools.commons.jci.compilers.AbstractJavaCompiler.compile(AbstractJa
vaCompiler.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/8128b877/attachment.html 


More information about the rules-users mailing list