我的目標是從我的軟件包中刪除對OSGi的依賴關係。我使用felix(v 4.2.1)作爲impl並運行它可嵌入。我安裝org.apache.felix.scr
(v。1.6.2)軟件包以具有Service Component Runtime支持。但是當我跑使用服務組件運行時
ServiceReference ref = bundleContext().getServiceReference(ScrService.class.getName());
ScrService s = (ScrService) bundleContext().getService(ref);
我得到ClassCastException: org.apache.felix.scr.impl.ComponentRegistry cannot be cast to org.apache.felix.scr.ScrService
。
好的。我將修改系統軟件包。
config.put(Constants.FRAMEWORK_SYSTEMPACKAGES, "org.apache.felix.scr");
現在,我得到
Caused by: org.osgi.framework.BundleException: Unresolved constraint in bundle org.apache.felix.scr [1]: Unable to resolve 1.0: missing requirement [1.0] osgi.wiring.package; (&(osgi.wiring.package=org.osgi.framework)(version>=1.4.0)(!(version>=2.0.0)))
at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:3974)
at org.apache.felix.framework.Felix.startBundle(Felix.java:2037)
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:955)
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:942)
at com.copyright.rup.communications.felix.Felix.addBundle(Felix.java:86)
... 28 more
我該如何解決呢?
是有點更清晰的瞭解是什麼原因造成了解析錯誤的問題的第二部分...通過FRAMEWORK_SYSTEMPACKAGES,他已刪除**所有**系統捆綁出口,除了'org.apache。 felix.scr'。所以,再見了'org.osgi.framework' ... bye bye'javax。*'...你得到了圖片。使用FRAMEWORK_SYSTEMPACKAGES_EXTRA *應該*修復它。 – 2013-04-22 19:57:25
+1應該明確提到。 – earcam 2013-04-22 22:47:32
謝謝。你幫了我很多。 – 2013-04-23 11:22:54