0

我对 osgi 和 bndtools 还很陌生,但在过去的几天里,我设法使用 bnd ant 任务创建 jar->bundle,并将我们的第 3 方 jar 包装为 bundle(对于那些尚未定义“Export-包'在清单文件中)。我必须评论说,bndtools 在出口和进口方面完成所有繁重的工作似乎很棒,所以感谢您在这个项目上的辛勤工作!

我有两个问题,也许你可以解释一下:

1

我正在尝试让捆绑包加载到 felix 中,并立即遇到解析错误。在这个基本场景中,我们有一个名为 omniquery_common 的内部包,它使用了几个 3rd 方 jar,包括 gson。当我解决我得到这个:

Unable to resolve <<INITIAL>> version=null:
   missing requirement Require[osgi.identity]{}{filter=(osgi.identity=omniquery_common)} [caused by:
   Unable to resolve omniquery_common version=1.0.0.0:
   missing requirement Require[osgi.wiring.package]{}{filter=(&(osgi.wiring.package=com.google.gson)(version>=2.2.0)(!(version>=3.0.0)))}]

对我来说,omniquery_common 正在导入 com.google.gson(版本至少为 2.2 且小于 3.0)。gson 包正在导出版本 2.2.4,所以这应该满足它的依赖关系,但不是。

你能帮我理解我是怎么弄错的吗?

omn​​iquery_common 的清单:

Manifest-Version: 1.0
Bnd-LastModified: 1442336803995
Bundle-ManifestVersion: 2
Bundle-Name: omniquery_common
Bundle-SymbolicName: omniquery_common
Bundle-Version: 1.0.0.0
Created-By: 1.8.0_40 (Oracle Corporation)
Export-Package: com.radian6.omni.common.osgi;version="1.0.0"
Import-Package: com.google.gson;version="[2.2,3)",com.radian6.omni.commo
 n.util,org.apache.commons.io;version="[1.4,2)",org.apache.commons.lang;
 version="[2.6,3)",org.junit
Private-Package: com.radian6.omni.common.core
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.7))"
Tool: Bnd-2.4.1.201501161923

gson 的清单:

Manifest-Version: 1.0
Export-Package: com.google.gson;version=2.2.4, com.google.gson.annotat
 ions;version=2.2.4, com.google.gson.reflect;version=2.2.4, com.google
 .gson.stream;version=2.2.4, com.google.gson.internal;version=2.2.4, c
 om.google.gson.internal.bind;version=2.2.4
Bundle-ClassPath: .
Built-By: inder
Bundle-Name: Gson
Created-By: Apache Maven 3.0.4
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-Vendor: Google Gson Project
Bundle-ContactAddress: http://code.google.com/p/google-gson/
Bundle-Version: 2.2.4
Build-Jdk: 1.7.0_21
Bundle-ManifestVersion: 2
Bundle-Description: Google Gson library
Bundle-SymbolicName: com.google.gson
Archiver-Version: Plexus Archiver

2

如果我更改“运行要求”列表中捆绑包的顺序,将 gson 捆绑包放在omniquery_common 之前,我会得到

Unable to resolve <<INITIAL>> version=null:
   missing requirement Require[osgi.identity]{}{filter=(osgi.identity=com.google.gson)}

我觉得不直观-我会认为该列表中的捆绑顺序无关紧要...?

4

1 回答 1

0

-runrequirements列表中需求的顺序确实很重要,因为如果列表中的早期有错误,那么我们就不会费心尝试解决它下面的所有问题。那就是:一旦我们知道解析不能成功,我们就退出并打印我们遇到的第一个错误。

您复制的第二条错误消息(当您首先提出 GSON 要求时)表明您的存储库中根本没有 GSON 捆绑包。或者,它不在解析器可见的存储库中。过滤器(osgi.identity=com.google.gson)失败,这意味着没有具有标识的资源com.google.gson

这也将解释您自己的omniquery_common包中的第一条错误消息。解析器找不到任何导出包的包com.google.gson,如果 GSON 包不存在,这将非常有意义。

因此,请查看您正在解析的存储库及其索引包含的内容。如果 GSON 确实出现在那里,那么我将需要更多信息来找出问题所在。

顺便说一句,一旦你完成了这项工作,你根本不需要在-runrequirements. 这就是解析器的重点:我们将根据您使用的包找到您的所有依赖项。

于 2015-09-17T16:24:01.973 回答