Drools 中不支持 Java 7(“RuntimeDroolsException:值‘1.7’不是有效的语言级别”)
当我将项目转移到 java7 时,Drools 在 init 过程中开始抛出 RuntimeDroolsException 异常。当我进一步挖掘时,我发现当它验证 java 方言时就会发生这种情况。
问题是:Drools 5.1.1 将“java.version”系统属性与 LANGUAGE_LEVELS 进行比较以验证它。 LANGUAGE_LEVELS 是硬编码的 java 版本列表,直到 1.6
In org.drools.rule.builder.dialect.java.JavaDialectConfiguration,
public static final String[] LANGUAGE_LEVELS = new String[]{"1.5", "1.6"};
我不想更改源代码。因此,我添加了以下内容作为绕过 java 方言验证的解决方法。
Properties properties = new Properties();
properties.setProperty( "drools.dialect.java.compiler.lnglevel","1.6" );
PackageBuilderConfiguration cfg =
new PackageBuilderConfiguration( properties );
KnowledgeBuilder knowledgeBuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(cfg);
除了编辑源代码之外,还有其他更好的方法吗?
PS:Drools 5.1.1是drools的最新生产版本
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
当您仍然想使用
Drools 5.1.1
时(切换到更高版本并不总是那么容易,因为规则不再编译),这可能是另一种非编程解决方法。在
META-INF/drools.packagebuilder.conf
中,您可以添加以下属性: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:中修复
此问题已在 5.2.1.FINAL 版本https://issues.jboss.org/browse/JBRULES -3163
This is fixed in 5.2.1.FINAL version
https://issues.jboss.org/browse/JBRULES-3163
我通过将引用的 drools-complier.jar 替换为 5.4.0.Final 版本解决了上述问题。我尝试了这个 jar 的早期版本,但出现了同样的错误。可以从 drools maven repo 下载此更新的 jar
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
最好的方法是向项目本身提交补丁并帮助他们支持 Java 7,然后在该版本可用后升级到该版本。
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.