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

As I move my project to java7, Drools starts throwing a RuntimeDroolsException during the init process. When I dig further, I found that this happens when it checks the java dialogs.

The problem is this: Drools 5.1.1 compares the java.version system property with LANGUAGE_LEVELS to check it. LANGUAGE_LEVELS is a hard-coded list of java versions up to 1.6

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

I did not want to change the source code. So I added the following as a workaround to get around the Java dialect check.

 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 a better way to do this other than editing the source code?

PS: Drools 5.1.1 - the latest production version of drool

+4
source share
4 answers

This is fixed in version 5.2.1.FINAL

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

+3
source

If you still want to use Drools 5.1.1 ( Drools 5.1.1 to a higher version is not always easy because the rules no longer compile), this might be another non-programmable 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 
+5
source

I solved this problem by replacing my drools-complier.jar link with version 5.4.0.Final. I tried previous releases of this jar, but the same error. Updated jar can be downloaded from drools maven repo

0
source

The best way is to provide the patch to the project itself and help them support Java 7, and then upgrade to this version when it is available.

-2
source

All Articles