Reputation: 4547
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
Upvotes: 5
Views: 13613
Reputation: 103
I solved the above problem by replacing my referenced drools-complier.jar with the 5.4.0.Final version. I tried earlier releases of this jar but the same error resulted. This updated jar can be downloaded from the drools maven repo
Upvotes: 0
Reputation: 63
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
Upvotes: 6
Reputation: 4547
This is fixed in 5.2.1.FINAL version
https://issues.jboss.org/browse/JBRULES-3163
Upvotes: 3
Reputation: 29912
The best way would be submitting a patch to the project itself and helping them support Java 7 as well and then upgrading to that version once it is available.
Upvotes: -2