Hi Jeff,
I am having the same question using Drools 6.4.0.Final. Did you ever got an answer or solve this issue?
--
You received this message because you are subscribed to the Google Groups "Drools Setup" group.
To unsubscribe from this group and stop receiving emails from it, send an email to drools-setup...@googlegroups.com.
To post to this group, send email to drools...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/drools-setup/af22fea8-a9c4-4fc3-a0eb-9819486d175f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
package com.infor.ion.rules;
import com.infor.ion.poc.rulesengine.api.model.detector.DetectorState;
import com.infor.ion.poc.rulesengine.api.model.BusinessEventData;
import java.util.ArrayList;
rule 'fc36dd77-b61e-4a84-aa8f-cb946ce1593c'
no-loop
when
$lst : ArrayList ( size == 3 ) from collect (
BusinessEventData(
getProperty('/SyncSalesOrder/sostatus') == 'Open'
) over window:time( #PERIOD# )
from entry-point 'SyncSalesOrder_stream'
)
then
DetectorState ds = new DetectorState();
ds.setDefinitionId('fc36dd77-b61e-4a84-aa8f-cb946ce1593c');
for (Object bed : $lst) {
ds.addBusinessEventData((BusinessEventData)bed);
}
ds.setEvaluationResult(true);
insert(ds);
$lst.clear();
end
Line 7, column 0: Rule Compilation error Syntax error, 'for each' statements are only available if source level is 1.5 or greater KieModuleModel kmm = this.ks.newKieModuleModel();
kmm.setConfigurationProperty("drools.dialect.java.lngLevel", "1.8");
kmm.setConfigurationProperty("drools.dialect.java.compiler.lnglevel", "1.8");
KieServices ks = KieServices.Factory.get();
KieFileSystem kf = ks.newKieFileSystem();
ReleaseId releaseId = ks.newReleaseId("com.infor.ion", "ACME_PRD.rules", "1.0.0-SNAPSHOT");
kf.writePomXML(createPomFile()); // POM file content given below
KieModuleModel kmm = ks.newKieModuleModel();
kf.writeKModuleXML(kmm.toXML());
kf.write("src/main/resources/ACME_PRD_MyRules.drl", "....." ); // the rules file given in previous post
KieBuilder kb = ks.newKieBuilder(kf);
kb.buildAll();
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.infor.ion</groupId>
<artifactId>acme.prd.rules</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>kjar</packaging>
<dependencies>
<dependency>
<groupId>com.infor.ion</groupId>
<artifactId>com.infor.ion.poc.rulesengine.api</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.kie</groupId>
<artifactId>kie-maven-plugin</artifactId>
<version>6.4.0.Final</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
</project>
2016-05-31 11:25:23,724 +0200Z {} INFO EngineModule com.infor.ion.poc.rulesengine.drools.DroolsCEPEngine: [web-request-0] System property: java.version=1.8
2016-05-31 11:25:23,724 +0200Z {} INFO EngineModule com.infor.ion.poc.rulesengine.drools.DroolsCEPEngine: [web-request-0] System property: drools.dialect.java.compiler.lnglevel=1.8
2016-05-31 11:25:24,540 +0200Z {} ERROR EngineModule org.drools.compiler.kie.builder.impl.AbstractKieModule: [web-request-0] Unable to build KieBaseModel:defaultKieBase
Rule Compilation error : [Rule name='d5ff31e0-cb98-4599-ae42-f29049f764db']
com/infor/ion/rules/Rule_d5ff31e0$u45$cb98$u45$4599$u45$ae42$u45$f29049f764db231039844.java (9:755) : Syntax error, 'for each' statements are only available if source level is 1.5 or greater
public static int findJavaVersion(ChainedProperties chainedProperties) {
String level = chainedProperties.getProperty(JAVA_LANG_LEVEL_PROPERTY,
System.getProperty("java.version"));
if ( level.startsWith( "1.5" ) ) {
return V1_5;
} else if ( level.startsWith( "1.6" ) ) {
return V1_6;
} else if ( level.startsWith( "1.7" ) ) {
return V1_7;
} else if ( level.startsWith( "1.8" ) ) {
return V1_8;
} else {
return V1_7;
}
}
While migrating code base to Open Jdk11 , Rule builder dialect uses default jdk 1.7 as drool compiler due to unsupported Java version 11.
As stated above because of default drool compiler V1_7, Rules having Lambda expression (1.8 compatible code) is failing with below error
Rule Compilation error : [Rule name='<rule name>']com/Rule_Name1212443411.java (13:1596) : Type mismatch: cannot convert from List<Object> to List<EmployeeSet>com/Rule_INamet1212443411.java (13:1637) : Lambda expressions are allowed only at source level 1.8 or above
Drools 6.5.0.Final will whitelist java up to 1.8 as valid lang level.
To proceed further either we have set “JAVA_LANG_LEVEL_PROPERTY" to 1.8 or to upgrade Drools engine to 7.36.1 version