简体   繁体   English

为什么即使解决了所有依赖关系,OSGi Bundle也无法启动?

[英]Why doesn't an OSGi Bundle start even when all the Dependencies are resolved?

1) Problem 1: 1)问题1:
I have come across this scenario quite a few times, finding transitive dependencies converting them to OSGi format and deploying them in OSGi container is already a pain. 我已经多次遇到这种情况,发现将传递依赖项转换为OSGi格式并将其部署到OSGi容器中已经很痛苦。

But sometimes even after doing the above, the bundle does not start WHY ? 但是有时即使完成上述操作后, 捆绑包仍无法启动,为什么?

I double checked the imports, all are satisfied, there are no red marks, but the bundle refuses to go "Active" it always shows "Installed". 我仔细检查了导入内容,所有内容都令人满意,没有红色标记,但是捆绑软件拒绝进入“有效”状态,它始终显示“已安装”。 Why does this happen? 为什么会这样?

2) Problem 2 2)问题2
Another issue I face is NoClassDefError occurring at runtime even when the class is present in Bundle and the bundle is Active. 我面临的另一个问题即使类存在于捆绑软件中且捆绑软件处于活动状态,运行时也会发生NoClassDefError

An example for this is org.apache.xmlbeans.XmlObject NoClassDefError org.apache.xmlbeans.XmlObject NoClassDefError就是一个例子。

If it is missing then it should show it in "red" as missing dependency, but instead it shows all dependencies resolved and bundle is Active? 如果缺少它,则应在“红色”中将其显示为缺少的依赖项,而是显示所有已解决的依赖项,并且捆绑包是否有效? I extracted the contents of the bundle as well to see if it is really there, and found out that it exists then why do these weird errors occur? 我还提取了捆绑软件的内容,以查看它是否确实存在,然后发现它存在,那么为什么会发生这些奇怪的错误呢?

Note: My working environment is Adobe CQ5. 注意:我的工作环境是Adobe CQ5。

在此处输入图片说明 在此处输入图片说明

  1. Simply start the bundle by hand from the shell (I hope CQ has a shell). 只需从外壳手动启动捆绑包(我希望CQ有外壳)。 It should show an exception that helps you. 它应该显示一个可以帮助您的异常。
  2. NoClassDefFound can happen if a bundle accesses a class but does not define an Import-Package statement for the package. 如果捆绑包访问一个类但未定义该包的Import-Package语句,则可能会发生NoClassDefFound。 If the class is even inside the same bundle then NoClassDefFound means that the bundle does not use the standard classloader. 如果该类甚至在同一包中,则NoClassDefFound表示该包不使用标准类加载器。 So maybe the bundle is not well prepared for OSGi. 因此,对于OSGi来说,捆绑包可能还没有做好充分的准备。 You should report such errors as an issue at the community that creates the bundle. 您应该在创建捆绑软件的社区中将此类错误报告为问题。

A likely cause for bundles not starting is their activators throwing exceptions. 捆绑包无法启动的可能原因是其激活器引发异常。 Those should be visible in the logs, and if not I would set a breakpoint in the bundle Activator to see what's happening. 这些应该在日志中可见,如果没有,我将在捆绑软件Activator中设置一个断点以查看发生了什么。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM