简体   繁体   English

(mis)了解osgi bundle的依赖关系

[英](mis)understanding osgi bundle dependencies

I'm pretty new to osgi and bndtools, but in the past couple days have managed to get jar->bundle creation working using bnd ant task, plus wrapping of our 3rd party jars as bundles (for those not already defining an 'Export-Package' in the manifest file). 我是osgi和bndtools的新手,但是在过去的几天里,使用bnd ant任务成功地使jar-> bundle创建工作,以及将我们的3rd party jars包装为捆绑包(对于那些尚未定义“导出-打包”(在清单文件中)。 I must comment that bndtools seems amazing for doing all the heavy lifting when it comes to exports and imports, so thank you to your hard work on this project! 我必须指出,bndtools在进行进出口方面的所有繁重工作看来都很棒,因此,感谢您在该项目上的辛勤工作!

i've got two issues that maybe you can shed some light on: 我有两个问题,也许您可​​以阐明一下:

1 1个

I'm trying to get the bundles to load in felix and am immediately running into resolution errors. 我正在尝试将捆绑软件加载到felix中,并立即遇到解析错误。 In this basic scenario, we have our in-house bundle called omniquery_common, which uses several 3rd party jars, including gson. 在这种基本情况下,我们拥有名为omniquery_common的内部捆绑包,其中使用了多个第3方jar(包括gson)。 when i resolve i get this: 当我解决我得到这个:

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)))}]

To me this says omniquery_common is importing com.google.gson (of a version at least 2.2 and less than 3.0). 对我来说,这表示omniquery_common正在导入com.google.gson(版本至少为2.2且小于3.0)。 the gson bundle is exporting version 2.2.4, so this should satisfy its dependency, but is not. gson捆绑包正在导出版本2.2.4,因此这应满足其依赖性,但事实并非如此。

can you help me understand how i am wiring this up wrong? 您能帮助我了解我如何将其接线错误吗?

manifest for omniquery_common: 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

manifest for gson: 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 2

if i alter the order of the bundles in the 'run requirements' list, putting the gson bundle before omniquery_common, i then get 如果我在“运行要求”列表中更改了捆绑包的顺序,将gson捆绑包放在omniquery_common之前,则可以

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

which i find unintuitive - i would have thought the bundle order in that list would not matter...? 我觉得这很不直观-我会认为该列表中的捆绑销售顺序没有关系...?

The order of the requirements in the -runrequirements list does matter, because if there is an error early in the list then we don't bother trying to resolve everything below it. -runrequirements列表需求的-runrequirements 确实很重要,因为如果列表的早期出现错误,那么我们就不用费劲尝试解决它下面的所有内容。 That is: once we know that the resolution cannot succeed, we just exit and print the first error we encountered. 也就是说:一旦我们知道解决方案无法成功,我们就退出并打印遇到的第一个错误。

The second error message you copied (when you put the GSON requirement first) suggests that you simply don't have the GSON bundle in your repository. 复制的第二条错误消息(当您首先提出GSON要求时)表明您的存储库中根本没有GSON捆绑包。 Or, it is not in a repository that is visible to the resolver. 或者,它不在解析程序可见的存储库中。 The filter (osgi.identity=com.google.gson) fails, which means there is no resource with the identity com.google.gson . 过滤器(osgi.identity=com.google.gson)失败,这意味着不存在标识为com.google.gson资源。

This would also explain the first error message from your own omniquery_common bundle. 这还将说明您自己的omniquery_common捆绑包中的第一个错误消息。 The resolver cannot find any bundle exporting the package com.google.gson , which would make perfect sense if the GSON bundle is not there. 解析器找不到任何导出软件包com.google.gson捆绑包,如果GSON捆绑包不存在,这将是很有意义的。

So, look into the repositories you are resolving against and what their indexes contain. 因此,请查看您要解决的存储库及其索引所包含的内容。 If GSON really does appear to be in there, then I will need further info on to figure out the problem. 如果GSON确实确实存在,那么我将需要更多信息以找出问题所在。

Incidentally, once you have this working, you shouldn't need to list GSON explicitly at all in -runrequirements . 顺便说一句,一旦完成此工作,就不需要在所有inrunrequirements中明确列出-runrequirements That is the point of the resolver: we will find all your dependencies based on the packages you used. 这就是解析器的重点:我们将根据您使用的软件包查找所有依赖项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 OSGI捆绑依赖项 - OSGI bundle dependencies OSGI捆绑软件中的依赖关系有问题 - Trouble with dependencies in an OSGI bundle 包含依赖项的简单 OSGi 应用程序 - Simple OSGi application with dependencies inside bundle 使用 maven-bundle-plugin 安装 OSGi 依赖项 - Installing OSGi dependencies with maven-bundle-plugin 在Netbeans和Karaf中开发OSGI捆绑包时如何管理依赖项? - How to manage dependencies when developing OSGI bundle in Netbeans and Karaf? Quartz Scheduler和Karaf上的使用依赖关系未启动OSGi捆绑包 - Quartz Scheduler and usage dependencies on Karaf not starting an OSGi bundle 在OSGi捆绑包中添加第三方Maven依赖项的最佳方法 - Best way to add Third party maven dependencies in OSGi bundle 在与maven一起使用OSGI包时如何隐藏嵌入式依赖项? - How to hide embedded dependencies when using an OSGI bundle with maven? 为OSGI容器创建一个Web应用程序包(WAB),该容器不包含maven-bundle-plugin的所有依赖项jar - Create a Web Application Bundle (WAB) for a OSGI container that does NOT contain jar of all dependencies with maven-bundle-plugin 为什么即使解决了所有依赖关系,OSGi Bundle也无法启动? - Why doesn't an OSGi Bundle start even when all the Dependencies are resolved?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM