简单的实验 -
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/