我无法向新类型声明添加字段。我是否需要.drl文件中每个类型声明的实际Java类?我以为那些是由Drools产生的?
这有效:
package tests
declare Person
end
现在添加一个字段(类型无关紧要):
package tests
declare Person
age : int
end
它会引发跟随错误。
java.lang.NoSuchMethodError: java.lang.String.isEmpty()Z
at org.drools.compiler.PackageBuilder.resolveType(PackageBuilder.java:1606)
at org.drools.compiler.PackageBuilder.fillFieldTypes(PackageBuilder.java:1672)
at org.drools.compiler.PackageBuilder.processTypeDeclarations(PackageBuilder.java:2008)
at org.drools.compiler.PackageBuilder.mergePackage(PackageBuilder.java:1272)
at org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:869)
at org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:466)
at org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:694)
at org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:51)
at org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:40)
at RuleTest.setUp(RuleTest.java:35)
at junit.framework.TestCase.runBare(TestCase.java:132)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
它出现在“Testrules.drl”行:
@Override
public void setUp() throws Exception {
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add( ResourceFactory.newClassPathResource( "Testrules.drl" ), ResourceType.DRL );
...
}
使用 Eclipse 3.4.2, Drools 5.5.0 Final
答案 0 :(得分:0)
方法String.isEmpty()似乎已在1.6(Java 6)中引入。删除旧的Java VM并安装当前版本(Java 7)解决了这个问题。