Error after converting org.pbjar library to OSGi bundle

扶醉桌前 提交于 2019-12-25 07:09:03

问题


I'm trying to convert org.pbjar.jxlayer library to an OSGi bundle, I already succeeded in that but when I try to install it in Karaf container, the container claims that there is a missing requirement needed by this bundle:

Unable to resolve 312.0: missing requirement [312.0] osgi.wiring.package; (osgi.wiring.package=com.sun.java.swing)

I also put the javax.swing in the bundle import directive but the problem persists I changed the version of JDK (1.5, 1.6, 1.7) but no luck

Can you help me please in resolving this problem.


回答1:


So your bundle tries to import the com.sun.java.swing package, and when the framework tries to resolve the bundle, it cannot find anybody exporting this package. That is what the error message is trying to tell you.

In Java 7 (I have not checked older versions) this package is part of the JRE. This means the easiest way to expose it to bundles is by having the framework export it as an "extra" package. You can configure a system property when starting your framework to do that:

-Dorg.osgi.framework.system.packages.extra=com.sun.java.swing

The other alternative you have is to embed this package inside your bundle. In that case you don't need to export it via the framework (which is convenient in case you cannot reconfigure your framework) and the import package can be removed from your bundle as well. If you end up having many bundles that need this, this is probably not that convenient or good, as you will end up with many private copies of the package (instead of everybody sharing one).



来源:https://stackoverflow.com/questions/23406448/error-after-converting-org-pbjar-library-to-osgi-bundle

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!