java - OSGi ( Felix ) 额外的 system.bundle 导出

标签 java jaxb osgi apache-felix bnd

简单的实验 -

bundle A 需要一些 com.sun.xml.internal.bind 类才能通过它的类加载器 ( jaxb.. ) 使用

我在谷歌上搜索了通过将包添加到“org.osgi.framework.system.packages.extra”(一个标准框架参数)来强制system.bundle导出com.sun.xml.internal.bind的理论解决方案在 felix 中实现,记录于 http://felix.apache.org/site/apache-felix-framework-configuration-properties.html )并将其导入我的包中。

这样做, bundle 将不再解析..

Unable to resolve 5.0: missing requirement [5.0] osgi.wiring.package; (osgi.wiring.package=com.sun.xml.internal.bind)

( 5 是使用 jaxb 的 bundle )为“com.sun.xml.internal.bind”设置“org.osgi.framework.bootdelegation”,并且不将其导入到依赖包中,按照文档说明进行操作。

我是否误解了 system.packages.extra 应该做什么?我可以不解析来自 system.bundle 的导入吗? 我尝试在 Import-Package 指令底部通过 bnd 在导入中显式设置 system.bundle

com.sun.xml.internal.bind;bundle-symbolic-name="system.bundle",\
*

这导致了

Unable to resolve 5.0: missing requirement [5.0] osgi.wiring.package; (&(osgi.wiring.package=com.sun.xml.internal.bind)(bundle-symbolic-name=system.bundle))

ps:我使用 bnd 和 -runproperties 来定义它们。我的 bndrun 文件有:

-runproperties: osgi.console.enable.builtin=true,\
com.mycompany.manager.confDir=./etc,\
org.osgi.framework.system.packages.extra=com.sun.xml.internal.bind,\
org.osgi.service.http.port=8888

需要 jaxb 的包定义了以下导入

Import-Package: com.sun.xml.internal.bind,\
    *

当尝试在 bndrun 编辑器中解决依赖项时,我得到

    Unable to resolve <<INITIAL>> ver=null: missing requirement (osgi.identity=com.mycompany.configuration.jaxb) [caused by: Unable to resolve com.mycompany.configuration.jaxb ver=0.0.0: missing requirement (osgi.wiring.package=com.sun.xml.internal.bind)]
org.osgi.service.resolver.ResolutionException: Unable to resolve <<INITIAL>> ver=null: missing requirement (osgi.identity=com.mycompany.configuration.jaxb) [caused by: Unable to resolve com.mycompany.configuration.jaxb ver=0.0.0: missing requirement (osgi.wiring.package=com.sun.xml.internal.bind)]
    at org.apache.felix.resolver.Candidates.populateResource(Candidates.java:285)
    at org.apache.felix.resolver.Candidates.populate(Candidates.java:153)
    at org.apache.felix.resolver.ResolverImpl.resolve(ResolverImpl.java:148)
    at biz.aQute.resolve.ResolveProcess.resolveRequired(ResolveProcess.java:34)
    at org.bndtools.core.resolve.ResolveOperation.run(ResolveOperation.java:61)
    at org.bndtools.core.resolve.ResolveJob.run(ResolveJob.java:43)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)

最佳答案

我发现您正在使用 Bndtools。好的!我们有一个特殊的属性用于从 .bndrun 文件设置系统包:

-runsystempackages: com.sun.xml.internal.bind

我不确定为什么当你将其放入 -runproperties 中时它不起作用......可能只是一个拼写错误,尽管我还没有发现它。无论如何,最好使用 -runsystempackages 因为这样 Bndrun 解析器也知道将这些包添加到系统 bundle 中;然后您也可以在 bndrun 编辑器中进行解析。

关于java - OSGi ( Felix ) 额外的 system.bundle 导出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20396158/

相关文章:

java - JAXB 列表解码不显示完整列表,而仅显示最后一个对象

java - Spring mvc - jsp MySQLSyntaxErrorException

java - 从 webview 打开原生 map

xpath - 我正在使用 docx4j 来读取 .docx 文件,我需要获取文档的段落并替换字符串

java - 5.0.0 以下版本的 Hibernate Karaf 功能

spring - 没有 Guice/Spring 的 JPA 交易痛苦更少

java - 如何分析 OSGi 部署的执行情况?

java - java@jboss4.0和linux环境找不到方法

java - 如何在 TextView Android 中将渐变设置为文本颜色以及在其周围添加描边?

java - JAXB 中的元素选择