【问题标题】:How to deploy Osgi Compendium Services in Karaf 4?如何在 Karaf 4 中部署 Osgi Compendium Services?
【发布时间】:2015-12-15 12:22:13
【问题描述】:

当我尝试部署使用 Compendium 服务的捆绑包时出现此错误:

Error executing command: Unable to resolve root: missing requirement [root]
...
osgi.wiring.package; filter:="(&(osgi.wiring.package=org.osgi.service.component)(version>=1.1.0)
(!(version>=2.0.0)))"]]

我的捆绑包已配置,因此它使用:

<dependency>
    <groupId>org.osgi</groupId>
    <artifactId>org.osgi.compendium</artifactId>
    <version>5.0.0</version>
</dependency>

根据karaf 4 depts documenation。 Osgi Compendium 版本是 5.0.0。这是否意味着我需要手动配置到 karaf compendium jar?是否有任何包含 Compendium Services 的 karaf 功能?

【问题讨论】:

    标签: java osgi apache-karaf


    【解决方案1】:

    纲要和核心 jar 包含 OSGi API。它们只能在构建时使用。不要将它们安装到 OSGi 中。核心 API 全部由 OSGi 框架包实现。纲要和企业 API 包包含太多不同的 API,无法在运行时使用。如果您安装它们,它们可能会与安装的其他 API 版本发生冲突而导致问题。

    相反,您需要提供一个实现 API 的包。然后,此捆绑包嵌入它实现的 API 包,或者您还需要安装仅包含此 API 包的 API 包。

    在您的情况下,您需要安装实现声明式服务规范的“scr”功能。

    【讨论】:

    • 嗨,Christian,我正在研究 UPnP OSGi 实现。到目前为止,我正在手动安装 osgi-compendium.jar(包含在我的功能中)。您的意思是最好在我的包中添加 UPnP OSGi API?
    • 你可以嵌入 api 包,但我更喜欢安装这个包 search.maven.org/…
    • 感谢您的建议,我会遵守的。非常感谢您的回答!!
    【解决方案2】:

    我找到了 Jean-Baptiste Onofré 的一句话

    嗨,鲍勃,

    Karaf 3.0.0 已经使用并发布了 org.osgi.core 和 org.osgi.compendium.

    所以是的,您可以将 5.0.0 用于核心、纲要和企业。

    问候 JB

    告诉 Karaf 运送 osgi 纲要。迁移到 5.0.0 版本后,我的 pom.xml 发生冲突,之前没有注意到。

    【讨论】:

    • Christian 是对的,您永远不应该在运行时安装纲要或企业 JAR。
    猜你喜欢
    • 2019-05-22
    • 2015-12-13
    • 2014-04-10
    • 2015-07-21
    • 1970-01-01
    • 2014-05-28
    • 2018-07-24
    • 2014-09-18
    • 2016-06-26
    相关资源
    最近更新 更多