1

我正在使用以下代码访问 Drools Guvnor:

KnowledgeAgentConfiguration kaconf = KnowledgeAgentFactory.newKnowledgeAgentConfiguration();
KnowledgeAgent kagent = KnowledgeAgentFactory.newKnowledgeAgent("MyAgent", kaconf);
kagent.applyChangeSet(ResourceFactory.newClassPathResource("drools/change-set.xml"));
StatefulKnowledgeSession ksession = kagent.getKnowledgeBase().newStatefulKnowledgeSession();

不幸的是KnowledgeAgentFactory,类似乎没有为 OSGI 做好准备,因为它用于Class.forName()加载代理提供程序。KnowledgeAgentFactory驻留在知识 API 包中,提供者实现在 drools-core 包中。显然,知识 API 在 OSGI 容器中看不到 drools-core。结果我得到以下异常:

Caused by: java.lang.RuntimeException: Provider org.drools.agent.impl.KnowledgeAgentProviderImpl could not be set.
    at org.drools.agent.KnowledgeAgentFactory.loadProvider(KnowledgeAgentFactory.java:191)[162:org.drools.api:5.5.0.Final]
    at org.drools.agent.KnowledgeAgentFactory.getKnowledgeAgentProvider(KnowledgeAgentFactory.java:178)[162:org.drools.api:5.5.0.Final]
    at org.drools.agent.KnowledgeAgentFactory.newKnowledgeAgentConfiguration(KnowledgeAgentFactory.java:129)[162:org.drools.api:5.5.0.Final]

这个问题有解决方法吗?

4

1 回答 1

0

您可能会使用 require-bundle 清单条目来帮助自己,因为它似乎无法与这些导入正常工作,我会说在这一点上让它以这种方式工作可能是最好的。

osgi wiki 中定义的Require-Bundle

于 2012-12-29T08:32:44.433 回答