【问题标题】:OSGI bundle exception caused by a 'uses constraint violation'由“使用约束违规”引起的 OSGI 捆绑异常
【发布时间】:2015-06-17 16:38:52
【问题描述】:

我正在尝试通过插件片段扩展 Eclipse PMD 插件中的规则。当我尝试测试我的代码时,我收到了这个错误,这似乎是由我的插件的依赖项目之一引起的。

!ENTRY net.sourceforge.pmd.eclipse.plugin 4 0 2015-06-17 09:30:10.972
!MESSAGE FrameworkEvent ERROR
!STACK 0
org.osgi.framework.BundleException: Could not resolve module: net.sourceforge.pmd.eclipse.plugin [1086]
  Bundle was not resolved because of a uses contraint violation.
  org.osgi.service.resolver.ResolutionException: Uses constraint violation. Unable to resolve resource net.sourceforge.pmd.eclipse.plugin [osgi.identity; osgi.identity="net.sourceforge.pmd.eclipse.plugin"; type="osgi.bundle"; version:Version="4.0.7.v20150522-1709"; singleton:="true"] because it exports package 'org.apache.log4j' and is also exposed to it from resource org.apache.log4j [osgi.identity; osgi.identity="org.apache.log4j"; type="osgi.bundle"; version:Version="1.2.15.v201012070815"] via the following dependency chain:

  net.sourceforge.pmd.eclipse.plugin [osgi.identity; osgi.identity="net.sourceforge.pmd.eclipse.plugin"; type="osgi.bundle"; version:Version="4.0.7.v20150522-1709"; singleton:="true"]
    require: (&(osgi.wiring.bundle=de.fu_berlin.inf.archnemesis)(bundle-version>=1.0.0))
     |
    provide: osgi.wiring.bundle; osgi.wiring.bundle="de.fu_berlin.inf.archnemesis"; bundle-version:Version="1.0.0.qualifier"; singleton:="true"
  org.eclipse.xtext.util [osgi.identity; osgi.identity="org.eclipse.xtext.util"; type="osgi.bundle"; version:Version="2.8.3.v201506010551"]
    import: (&(osgi.wiring.package=org.apache.log4j)(version>=1.2.15))
     |
    export: osgi.wiring.package: org.apache.log4j
  org.apache.log4j [osgi.identity; osgi.identity="org.apache.log4j"; type="osgi.bundle"; version:Version="1.2.15.v201012070815"]
    at org.eclipse.osgi.container.Module.start(Module.java:434)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1582)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1561)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1533)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1476)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1)
    at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
    at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340)

任何人都可以解码此错误消息的含义以及如何解决它吗?

【问题讨论】:

    标签: java eclipse osgi osgi-bundle


    【解决方案1】:

    我认为问题是由于net.sourceforge.pmd.eclipse.plugin 捆绑包中的Require-Bundle 指令加上org.apache.log4jExport-Package 指令(这或多或少只是对felix 错误消息的改写)。

    所需的包 de.fu_berlin.inf.archnemesis 导入 log4j,同时 et.sourceforge.pmd.eclipse.plugin 在其类路径中有 log4j jars(因为它导出它,这就是它告诉你的错误消息)。这会导致 org.apache.log4j 包重复并触发错误。

    尝试从运行时中删除 org.apache.log4j 包,以便让 de.fu_berlin.inf.archnemesis 解析来自 net.sourceforge.pmd.eclipse.plugin 的 log4。

    另请阅读this post Neil Bartlett 关于解决 OSGi“使用”约束冲突:我发现它非常有趣。

    【讨论】:

      猜你喜欢
      • 2017-04-28
      • 2022-01-23
      • 2021-12-05
      • 2016-08-14
      • 2015-11-03
      • 2019-04-29
      • 1970-01-01
      • 2018-06-28
      • 2018-01-10
      相关资源
      最近更新 更多