【问题标题】:Bundle was not resolved because of a uses contraint violation in karaf由于 karaf 中的使用约束违规,Bundle 未解决
【发布时间】:2021-08-14 09:43:14
【问题描述】:

如何克服这个链依赖问题?

Error executing command: Error executing command on bundles:
        Error starting bundle 429: Could not resolve module: com.sample.eventhistory [429]
  Bundle was not resolved because of a uses contraint violation.
  org.osgi.service.resolver.ResolutionException: Uses constraint violation. Unable to resolve resource com.sample.eventhistory [osgi.identity; osgi.identity="com.sample.eventhistory"; type="osgi.bundle"; version:Version="1.90.0.SNAPSHOT"] because it exports package 'com.sample.restenquiry.exceptions' and is also exposed to it from resource com.sample.eventhistory [osgi.identity; osgi.identity="com.sample.eventhistory"; type="osgi.bundle"; version:Version="1.90.0.SNAPSHOT"] via the following dependency chain:

 

  com.sample.eventhistory [osgi.identity; osgi.identity="com.sample.eventhistory"; type="osgi.bundle"; version:Version="1.90.0.SNAPSHOT"]
    import: (osgi.wiring.package=com.sample.restutil.impl)
     |
    export: osgi.wiring.package=com.sample.restutil.impl; uses:=com.sample.restservice
  rest [osgi.identity; osgi.identity="edmexporest"; type="osgi.bundle"; version:Version="1.90.0.SNAPSHOT"]
    import: (&(osgi.wiring.package=com.sample.restservice)(&(version>=1.90.0)(!(version>=2.0.0))))
     |
    export: osgi.wiring.package: com.sample.restservice; uses:=com.sample.restenquiry.exceptions
    export: osgi.wiring.package=com.sample.restenquiry.exceptions
  com.sample.eventhistory [osgi.identity; osgi.identity="com.sample.eventhistory"; type="osgi.bundle"; version:Version="1.90.0.SNAPSHOT"]

在部署捆绑服务时没有出现。而是在 karaf 控制台中出现上述错误

【问题讨论】:

    标签: java osgi bundle apache-karaf


    【解决方案1】:

    OSGi 允许导出相同的包——只要版本号不同。在这种情况下,您有相同的包+版本被两个包导出。

    一个好的做法是将接口和异常放在一个包中(即service-api),然后消费者包和提供者包都可以导入这些包,但不需要你让消费者直接依赖提供者.

    【讨论】:

    • 我在将 Apache felix 迁移到 DS 实现时遇到了这个问题[osgi]。我在我的 pom.xml @MattPavlovich 中使用 maven-bundle-plugin 版本 3.2.0
    猜你喜欢
    • 2017-04-28
    • 2019-06-02
    • 2014-01-13
    • 2020-03-28
    • 1970-01-01
    • 1970-01-01
    • 2011-04-19
    • 2022-01-23
    • 2015-11-03
    相关资源
    最近更新 更多