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
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