No support for Java 7 in Drools ("RuntimeDroolsException: value '1.7' is not a valid language level")

13,478

Solution 1

This is fixed in 5.2.1.FINAL version

https://issues.jboss.org/browse/JBRULES-3163

Solution 2

When you still want to use Drools 5.1.1 (switching to a higher version is not always easy because rules do not compile anymore), this might be another, non-programmatic workaround.

In META-INF/drools.packagebuilder.conf you can add these properties:

 drools.dialect.java.compiler = ECLIPSE 
 drools.dialect.java.lngLevel = 1.6 
 drools.dialect.java.compiler.lnglevel = 1.6
Share:
13,478
Bala
Author by

Bala

Happy to help.

Updated on June 04, 2022

Comments

  • Bala
    Bala about 2 years

    While I'm moving my project to java7, Drools starting throwing RuntimeDroolsException exception during init process. When i dig further, I found that this is happening when it validates java dialect.

    The problem is: Drools 5.1.1 compares "java.version" system property with LANGUAGE_LEVELS to validate it. LANGUAGE_LEVELS is hard-coded list of java versions till 1.6

    In org.drools.rule.builder.dialect.java.JavaDialectConfiguration,
    public static final String[]        LANGUAGE_LEVELS = new String[]{"1.5", "1.6"};
    

    I didn't want to change the source code. So I added the below as a workaround to bypass java dialect validation.

    Properties properties = new Properties();
    properties.setProperty( "drools.dialect.java.compiler.lnglevel","1.6" );
    PackageBuilderConfiguration cfg =
    new PackageBuilderConfiguration( properties );
    KnowledgeBuilder knowledgeBuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(cfg);
    

    Is there any better way of doing this other than editing source code?

    P.S: Drools 5.1.1 is the latest production version of the drools

  • Damian Leszczyński - Vash
    Damian Leszczyński - Vash over 12 years
    That fine but, i think that extending the array might be not enough.
  • Simon Forsberg
    Simon Forsberg almost 8 years
    This answer is incredibly obsolete by now, and was in my opinion not really a good answer to begin with.