Java 从OSGI捆绑包访问Drools Guvnor

Java 从OSGI捆绑包访问Drools Guvnor,java,osgi,drools,guvnor,Java,Osgi,Drools,Guvnor,我使用以下代码访问Drools Guvnor: KnowledgeAgentConfiguration kaconf = KnowledgeAgentFactory.newKnowledgeAgentConfiguration(); KnowledgeAgent kagent = KnowledgeAgentFactory.newKnowledgeAgent("MyAgent", kaconf); kagent.applyChangeSet(ResourceFactory.newClassPat

我使用以下代码访问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位于KnowledgeAPI包中,提供者实现位于drools核心包中。显然,KnowledgeAPI并没有在OSGI容器中看到drools核心。因此,我得到以下异常:

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]

是否有解决此问题的方法?

您可能需要一个require bundle manifest条目,因为它似乎无法正确地处理这些导入,我想说,在这一点上,最好是让它以这种方式工作


正如osgi wiki中定义的那样,Require Bundle和Import Bundle在这里似乎都有帮助