Why isn't Drools working with Java 8?

不羁岁月 提交于 2019-11-30 17:14:18

Looks like a bug in Drools (in the Eclipse compiler which is the default):

They're looking into fixing it in 6.1.0.Beta2.

Meanwhile, try this workaround: Override the ecj dependency to version 4.3.1.

I have solved this issue by edit pom in maven.

    <dependency>
        <groupId>org.eclipse.jdt.core.compiler</groupId>
        <artifactId>ecj</artifactId>
        <version>4.5.1</version>
    </dependency>

    <!-- core -->
    <dependency>
        <groupId>org.drools</groupId>
        <artifactId>drools-core</artifactId>
        <version>5.5.0.Final</version>
    </dependency>
    <dependency>
        <groupId>org.drools</groupId>
        <artifactId>drools-compiler</artifactId>
        <version>5.5.0.Final</version>
        <exclusions>
            <exclusion>
                <groupId>org.eclipse.jdt.core.compiler</groupId>
                <artifactId>ecj</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

Update your org.eclipse.jdt.internal.compiler(ecj.jar) to latest i.e, use ecj-4.4.jar and try.

ECJ, which is used to compile java code in your rules, only began supporting Java 8 syntax recently with Luna (4.4) so an update is required.

If you are wanting to use Java 8 syntax in your rules you will also want to use Drools 6.4.0.Final as they now recognizing Java 8 as Java 8 (they were mapping 8 over to 7 to fix issues with ECJ 4.3)

MVEL 2.2.X version or later, which is a shorthand alternative to Java syntax, also supports Java 8.

Update org.eclipse.jdt.core.jar to latest available one .

In our case we have updated org.eclipse.jdt.core-3.5.1.v_972_R35x.jar to org.eclipse.jdt.core_3.11.2.v20160128-0629.jar .

This is the jar which decides the java_version with which the drools code will get compiled.

once ur old java-6 compatible drools code getting compiled in java -8 . u can run it using java -8 without any such error . These are proven steps . Please revert back if any doubt .

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!