gpt4 book ai didi

drools - 尝试使用来自 guvnor 的 changeset.xml 读取规则会导致错误

转载 作者:行者123 更新时间:2023-12-04 18:16:41 26 4
gpt4 key购买 nike

我尝试使用以下代码从 Guvnor 加载包:-

    KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource("GenderFact.xml"),ResourceType.CHANGE_SET);
System.out.println("fair trial");
KnowledgeBuilderErrors errors = kbuilder.getErrors();
if (errors.size() > 0) {
for (KnowledgeBuilderError error: errors) {
System.err.println(error);
}
throw new IllegalArgumentException("Could not parse knowledge.");
}
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
return kbase;

GenderFact.xml 的内容是:-
<change-set xmlns="http://drools.org/drools-5.0/change-set"
xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
xs:schemaLocation="http://drools.org/drools-5.0/change-set http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-api/src/main/resources/change-set-1.0.0.xsd">
<add>
<resource
source="http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/MyLastTrial/LATEST/"
type="PKG" basicAuthentication="disabled" username="admin" password="admin" />
</add>

当我尝试从 Eclipse 执行此操作时,出现以下错误:-

java.lang.RuntimeException: java.io.InvalidClassException: org.drools.rule.MVELDialectRuntimeData; local class incompatible: stream classdesc serialVersionUID = 5166066541265170937, local class serialVersionUID = -64624826351992706 at org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:705) at org.drools.compiler.PackageBuilder.addPackageFromChangeSet(PackageBuilder.java:772) at org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:694) at org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:45) at org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:34) at com.sample.DroolsTest.readKnowledgeBase(DroolsTest.java:43) at com.sample.DroolsTest.main(DroolsTest.java:26) Caused by: java.io.InvalidClassException: org.drools.rule.MVELDialectRuntimeData; local class incompatible: stream classdesc serialVersionUID = 5166066541265170937, local class serialVersionUID = -64624826351992706 at java.io.ObjectStreamClass.initNonProxy(Unknown Source) at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source) at java.io.ObjectInputStream.readClassDesc(Unknown Source) at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source) at java.io.ObjectInputStream.readObject0(Unknown Source) at java.io.ObjectInputStream.readObject(Unknown Source) at java.util.HashMap.readObject(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at java.io.ObjectStreamClass.invokeReadObject(Unknown Source) at java.io.ObjectInputStream.readSerialData(Unknown Source) at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source) at java.io.ObjectInputStream.readObject0(Unknown Source) at java.io.ObjectInputStream.readObject(Unknown Source) at org.drools.rule.DialectRuntimeRegistry.readExternal(DialectRuntimeRegistry.java:59) at java.io.ObjectInputStream.readExternalData(Unknown Source) at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source) at java.io.ObjectInputStream.readObject0(Unknown Source) at java.io.ObjectInputStream.readObject(Unknown Source) at org.drools.rule.Package.readExternal(Package.java:208) at java.io.ObjectInputStream.readExternalData(Unknown Source) at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source) at java.io.ObjectInputStream.readObject0(Unknown Source) at java.io.ObjectInputStream.readObject(Unknown Source) at org.drools.core.util.DroolsStreamUtils.streamIn(DroolsStreamUtils.java:205) at org.drools.core.util.DroolsStreamUtils.streamIn(DroolsStreamUtils.java:189) at org.drools.compiler.PackageBuilder.addPackageFromInputStream(PackageBuilder.java:781) at org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:692) ... 6 more



先决条件:-
  • 我将 Guvnor 5.3 与 jboss AS 7.0 一起使用。
  • 客户端和服务器都共享同一个 jre7。
  • Eclipse Indigo 中的 Drools 运行时 5.3(服务版本 2)

  • 请求解决方法...

    最佳答案

    java 项目中使用的 Drools 相关 jar 与 GUvnor 5.3 中使用的版本不同。
    使用 Guvnor 5.3 中的 jar 到您的 java 项目中。
    它将解决问题。 :)

    关于drools - 尝试使用来自 guvnor 的 changeset.xml 读取规则会导致错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11535422/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com