OSGi 功能卸载有效,但 bundle 仍然安装

标签 osgi apache-karaf apache-felix apache-servicemix fuseesb

编辑:用最新信息更新了此问题...

我在连续运行依赖功能的“features:uninstall”命令时遇到问题。 OSGi 响应“状态更改正在进行中...”,但是通过接受其他请求,我们遇到了问题。

奇怪的是,这会导致功能卸载成功,但 bundle 卸载失败。我们正在通过尝试适本地排序卸载请求并在步骤之间添加延迟来解决此问题,但我希望有一个更强大的解决方案。

按照建议,我还尝试在步骤之间添加“osgi:refresh”...相同的行为。是否有另一种方法可以检测“刷新包”仍在运行以延迟后续请求等?

这是详细信息...

karaf@root> features:uninstall PolicyUtil  
karaf@root> features:uninstall Policy1  
karaf@root> features:uninstall Policy2    
State change in progress for bundle "file:/policy2.jar" by thread "Refresh Packages".  
karaf@root> features:uninstall Policy3  
State change in progress for bundle "file:/policy3.jar" by thread "Refresh Packages".  
karaf@root> features:uninstall Policy4  
karaf@root> features:uninstall Enabler1    
State change in progress for bundle "file:/enabler1.jar" by thread "Refresh Packages".    
karaf@root> features:uninstall Enabler2  
State change in progress for bundle "file:/enabler2.jar" by thread "Refresh Packages".  

afterwards...we end up with features uninstalled (correct), but some bundles still installed (incorrect)

osgi:list

[ 277] [Installed  ] [            ] [       ] [   60] Policy2  
[ 278] [Installed  ] [            ] [       ] [   60] Policy3  
[ 280] [Installed  ] [            ] [       ] [   60] Enabler1  
[ 281] [Installed  ] [            ] [       ] [   60] Enabler2  

features:list

[uninstalled] [1.0                 ] PolicyUtil                           repo-0  
[uninstalled] [1.0                 ] Policy1                              repo-0  
[uninstalled] [1.0                 ] Policy2                              repo-0  
[uninstalled] [1.0                 ] Policy3                              repo-0  
[uninstalled] [1.0                 ] Enabler1                             repo-0  
[uninstalled] [1.0                 ] Enabler2                             repo-0  

最佳答案

我不确定您会得到什么样的异常,但您应该注意一件事:当您使用 osgi:uninstall 这样的 shell 命令卸载 bundle 时,您实际上调用了 Bundle.uninstall() 。正如您可以在 Javadoc 中读到的那样,这并不是故事的全部。

该框架倾向于对框架其余部分影响最小的操作,因此它可以卸载 bundle ,而无需删除所有相关包。如果您确实想删除所有这些,您应该使用 osgi:refresh 命令。有关详细信息,请参阅 Felix FAQ

我能给出的最好建议是不要发出多个可能相互交叉的卸载请求。如果您想删除一组 bundle ,我会触发非交叉 uninstall() 请求,然后是单个 refreshPackages() 。另外,我不会在单个系统中混合使用“常规”控制台和 Karaf 进行捆绑管理。

您还可以考虑使用外部管理器来安装和删除 bundle 。如果您想要远程管理,您可以选择 Apache ACE(披露:我是 Apache ACE 提交者)。

关于OSGi 功能卸载有效,但 bundle 仍然安装,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4540414/

相关文章:

eclipse - 由于 OSGI BundleException,GWT 插件无法在使用 JDK 11 或 17 的 Eclipse 2022-03 中加载

java - 尽管有 Import-Package,但 org.osgi.framework.BundleActivator 的 ClassNotFoundException

java - OSGI - 将实体拆分为多个包

java - 如何在两个项目之间进行回调?

java - 在 Osgi 中以编程方式注册 ServletContainer

linux - 解决 Apache Felix 启动时 already in use 报错

java - 为什么在 Apache Felix 中运行时 JAXB 找不到我的 jaxb.in​​dex?

maven - Felix 1.4.0 OSGi 中的 Axis2

java - JBoss Fuse 和应用服务器之间的区别

java - 重定向到 Java 程序?