将 org.pbjar 库转换为 OSGi 包后出错 [英] Error after converting org.pbjar library to OSGi bundle

查看:34
本文介绍了将 org.pbjar 库转换为 OSGi 包后出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将 org.pbjar.jxlayer 库转换为 OSGi 包,我已经成功了,但是当我尝试将它安装在 Karaf 容器中时,该容器声称此包缺少一个要求:

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:

无法解析 312.0:缺少需求 [312.0] osgi.wiring.package;(osgi.wiring.package=com.sun.java.swing)

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

我也将 javax.swing 放在了 bundle import 指令中,但问题依然存在我更改了 JDK 的版本(1.5、1.6、1.7)但没有运气

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.

推荐答案

所以你的包尝试导入 com.sun.java.swing 包,当框架尝试解析包时,它找不到任何人导出这个包.这就是错误消息试图告诉您的内容.

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.

在 Java 7 中(我没有检查过旧版本)这个包是 JRE 的一部分.这意味着将它公开给包的最简单方法是让框架将其作为额外"包导出.您可以在启动框架时配置系统属性来执行此操作:

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).

这篇关于将 org.pbjar 库转换为 OSGi 包后出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆