我尝试使用以下代码从 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;本地类不兼容:流classdesc serialVersionUID = 5166066541265170937,本地类serialVersionUID = -64624826351992706 at org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:705) at org.drools.compiler.PackageBuilder.addPackageFromChangeSet(PackageBuilder.java:772)在 org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:694) 在 org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:45) 在 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) 原因:java.io.InvalidClassException: org. drools.rule.MVELDialectRuntimeData; 本地类不兼容:流classdesc serialVersionUID = 5166066541265170937,本地类serialVersionUID = -64624826351992706 at java.io.ObjectStreamClass.initNonProxy(Unknown Source) at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source) at java.io.ObjectInputStream.readClassDesc(Unknown源) 在 java.io.ObjectInputStream.readOrdinaryObject(Unknown Source) 在 java.io.ObjectInputStream.readObject0(Unknown Source) 在 java.io.ObjectInputStream.readObject(Unknown Source) 在 java.util.HashMap.readObject(Unknown Source)在 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 在 sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 在 java.lang.reflect.Method。
先决条件:-
- 我将 Guvnor 5.3 与 jboss AS 7.0 一起使用。
- 客户端和服务器都共享同一个 jre7。
- Eclipse Indigo 中的 Drools 运行时 5.3(服务版本 2)
请求解决方法...