1
我使用以下代碼訪問的Drools的Guvnor:訪問的Drools的Guvnor從OSGi包
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 bundle中提供實現。顯然knowledge-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]
是否有解決此問題的方法?
定義都需要束和Import-捆綁似乎在這裏幫助 – hoaz