OSGi捆绑包状态未激活(CQ5 Maven项目)为什么? [英] OSGi Bundle status is not Active (CQ5 Maven Project) WHY?

查看:141
本文介绍了OSGi捆绑包状态未激活(CQ5 Maven项目)为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道当安装了CQ中捆绑软件的状态时,存在依赖关系,这就是为什么捆绑软件不能处于活动"状态的原因.

I know that when the status of a bundle in CQ is installed, there are dependencies and that is why the bundle cannot be "Active".

我在CQ5服务中使用的是Jersey Client v 2.17,所以我需要Jersey Core Client Jar.我在/bundle/pom.xml 中添加了依赖项.我的捆绑包成功编译并部署了但从未启用

I am using a Jersey Client v 2.17 in a CQ5 Service, so I need the Jersey Core Client Jar. I added the dependency in the /bundle/pom.xml. My bundle successfully compiles and deploys BUT NEVER TURNS ACTIVE

我手动在Felix Console中添加了Jersey客户端Jar,通过激活我的捆绑包,但 Jersey客户端Jar未激活,所以我一直收到 ClassNotFoundError 在Jersey客户端Jar中也是传递依赖项.

I added the Jersey Client Jar in Felix Console manually, by doing this my bundle got activated but the Jersey Client Jar is not active so I keep getting ClassNotFoundError as there are transitive dependencies in the Jersey Client Jar as well.

我尝试了以下操作:

  1. 通过在Felix Console中添加Jars手动尝试解决依赖关系. 我失败.循环永无止境(传递依赖项)
  2. 通过更改Jersey Core Client Jar的清单进行了一些调整,我添加了DynamicImport-Package: *.这欺骗了OSGi容器,即在运行时将找到Jars.过去这对我有用,但是现在它需要一些不存在的类.( Jars Jersey Client和My Bundle都被激活,但是我得到了 找不到类,因为实际上实际上是不存在 我尝试欺骗OSgi Conatainer多少钱)失败.
  3. 所以尝试了另一件事,我在/bundle/pom.xml 中添加了所有依赖的Jar.当我使用Maven时,我以为这可以解决问题,但是我的捆绑包仍然已安装而不是活动
  1. Manually tried resolving dependencies by adding Jars in Felix Console. I failed. The Loop never ends(Transitive Dependencies)
  2. I tried some tweaking by changing the manifest of the Jersey Core Client Jar, I added DynamicImport-Package: *. This tricks the OSGi conatainer, that at runtime it will find the Jars. This has worked for me in the past but now it needs some classes that aren't present.(Both Jars the Jersey Client and My Bundle become active BUT I get class NOT found Error as the classes are actually not there no matter how much I try to fool the OSgi Conatainer)Failed.
  3. So tried another thing, I added all the dependent Jars in the /bundle/pom.xml. As I am using Maven I thought this would solve the issue but my bundle is still Installed NOT Active

我的第三步是一个惨痛的失败.无论如何,无论如何在Felix控制台中手动安装所有Jars,Maven对您有什么好处?!

我该怎么办?

推荐答案

首先,Maven仅在构建时依赖项方面为您提供帮助,并且Maven依赖项位于jar级别.将捆绑软件安装到OSGi容器中时,必须处理程序包级别的运行时依赖项.

First of all, Maven only helps you with build-time dependencies, and Maven dependencies are at the jar level. When installing bundles into an OSGi container, you have to deal with run-time dependencies, which are at the package level.

因此,构建时间与运行时间不匹配,因为依赖项的工作方式不同.您可能会说,Maven根本不是一个很好的选择,这就是为什么至少有些做很多OSGi应用程序的人已切换到Bnd/Bndtools和命令行Gradle构建的原因.

So there is a mismatch between build-time and run-time, as dependencies work differently. You could argue that Maven is not that good a match at all, which is why at least some people that do a lot of OSGi applications have switched to Bnd/Bndtools and a command-line Gradle build.

回到您的问题.您在运行时遇到缺少的依赖项.您的捆绑软件正在导入未由任何捆绑软件导出的软件包.要解决此问题,您可以使用以下两种策略之一:

Back to your problem. You are running into missing dependencies at runtime. Your bundle is importing packages that are not exported by any bundle. To fix that, you can use one of two strategies:

  1. 您可以将所需的所有依赖项嵌入到包中.实际上,您需要在此嵌入Jersey客户端(以及传递其所需的所有依赖项).您不会将其中任何一个暴露给其他捆绑软件,所有代码都将最终出现在您的捆绑软件中.
  2. 您可以将所需的所有依赖项安装为捆绑包.这意味着您需要暂时找到运行Jersey客户端所需的所有软件包.有一些工具可以帮助您. Maven不是其中之一.

希望这会有所帮助.可能不是您希望听到的.

Hope this helps. It might not be what you were hoping to hear.

这篇关于OSGi捆绑包状态未激活(CQ5 Maven项目)为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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