Reputation: 11
I'm using Drools (5.5.0) rules in my Java project (managed using maven 2.2.1). It works fine in Java 6 (1.6.0_45), but when I move to Java 7 (1.7.0_51) and build, certain rules give a rule compilation error such as the following:
Rule Compilation error : [Rule name='SampleRuleName']
com/sample/event/rules/simple/Rule_SampleRuleName46467274.java (2:486) : Syntax error, static imports are only available if source level is 5.0
com/sample/event/rules/simple/Rule_SampleRuleName46467274.java (2:500) : The import com.sample.event.rules.simple.TransformEvent.transformEvent cannot be resolved
com/sample/event/rules/simple/Rule_SampleRuleName46467274.java (7:1082) : The method transformEvent(TransformedEventCallBackHandler, EventTemplate, FirmwareEvent) is undefined for the type Rule_SampleRuleName46467274
The "static imports are only available if source level is 5.0" error suggests the drools compiler is setting a source level less than 5, but why would it do that? I've update my JAVA_HOME and my pom.xml. It should be picking up the Java source level from there, right?
Upvotes: 0
Views: 2248
Reputation: 11
Turns out Drools uses the Eclipse JDT compiler to compile rules. Upgrading the JDT version did the trick. However if that fails, upgrading the Drools version might also help.
Upvotes: 1
Reputation: 27357
Upgrade to Drools 6, this issue is fixed there. We had a similar issue for Java 8 recently with Drools 6.0 and it's fixed for 6.1 (and recent versions of 6.0 too).
The cause for java 8 was that drools recognizes java versions 1.6, 1.7, but not 1.8 at which point it defaults to 1.6. I suspect that drools 5.5 (which is old) had the same problem for java 7.
Upvotes: 1