Eclipse 由于使用约束冲突,未解析捆绑包

Eclipse 由于使用约束冲突,未解析捆绑包,eclipse,osgi,rcp,Eclipse,Osgi,Rcp,我在现有的EclipseRCP应用程序中引入了一个第三方插件,现在我的日志不再工作了。它似乎在使用自己版本的slf4j。我如何解决这个问题,让我的slf4j和第三方jar中的slf4j和谐共存 Bundle was not resolved because of a uses contraint violation. org.osgi.service.resolver.ResolutionException: Uses constraint violation. Unabl

我在现有的EclipseRCP应用程序中引入了一个第三方插件,现在我的日志不再工作了。它似乎在使用自己版本的slf4j。我如何解决这个问题,让我的slf4j和第三方jar中的slf4j和谐共存

  Bundle was not resolved because of a uses contraint violation.
    org.osgi.service.resolver.ResolutionException: Uses constraint violation. 
    Unable to resolve resource My3rdPartyLib.my3rdPartyLib_api [osgi.identity; 
    osgi.identity="My3rdPartyLib.my3rdPartyLib_api"; type="osgi.bundle"; 
    version:Version="2.4"] because it is exposed to package 'org.slf4j' 
    from resources slf4j.api [osgi.identity; osgi.identity="slf4j.api"; 
    type="osgi.bundle"; version:Version="1.7.21"] and activemq-all 
    [osgi.identity; osgi.identity="activemq-all"; type="osgi.bundle"; 
    version:Version="5.9.0"] via two dependency chains.

Chain 1:
  My3rdPartyLib.my3rdPartyLib_api [osgi.identity; 
   osgi.identity="My3rdPartyLib.my3rdPartyLib_api"; type="osgi.bundle"; 
   version:Version="2.4"]
    import: (osgi.wiring.package=org.slf4j)
     |
    export: osgi.wiring.package: org.slf4j
  slf4j.api [osgi.identity; osgi.identity="slf4j.api"; 
   type="osgi.bundle"; version:Version="1.7.21"]

Chain 2:
  My3rdPartyLib.my3rdPartyLib_api [osgi.identity; 
   osgi.identity="My3rdPartyLib.my3rdPartyLib_api"; type="osgi.bundle"; 
   version:Version="2.4"]
    import: (osgi.wiring.package=org.apache.activemq)
     |
    export: osgi.wiring.package: org.apache.activemq; uses:=org.slf4j
    export: osgi.wiring.package=org.slf4j
  activemq-all [osgi.identity; osgi.identity="activemq-all"; 
   type="osgi.bundle"; version:Version="5.9.0"]
    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)
我试着把它作为一个RCP插件。在target->content视图中,我选中了第三方jar及其必要的依赖项。我还选中了我需要的slf4j罐子。如果我运行产品->验证,它会显示“未检测到问题”。当我运行它时,它会弹出上面显示的消息


任何帮助都将不胜感激

为什么My3rdPartyLib.My3rdPartyLib_api要导出slf4j.api?也许您可以将其更改为仅导入它。您不会显示activemq all是否也导出slf4j.api。一个想法可能不是全部使用activemq,而是使用您需要的单个activemq部分-所有捆绑包都很方便,但它们在uber捆绑包中的包可以修复某些影响系统其他部分的约束

为什么My3rdPartyLib.My3rdPartyLib_api要导出slf4j.api?也许您可以将其更改为仅导入它。您不会显示activemq all是否也导出slf4j.api。一个想法可能不是全部使用activemq,而是使用您需要的单个activemq部分-所有捆绑包都很方便,但它们在uber捆绑包中的包可以修复某些影响系统其他部分的约束

两个清单在“使用”部分都有多个关于slf4j导出的条目。我不确定如果我把它们拿走会发生什么。我认为应该有一种方法让插件可以共存,而不用我编辑它们的清单(特别是因为我没有编写它们)。RCP/OSGI不支持这一点吗?列在uses指令中并不意味着它是导出。这确实意味着所用包中的类型在导出包的API中可见。当同一类型名称的不同类对象相遇时,从使用中删除会导致运行时ClassCastException。我想说,这里的一些错误在于activemq,因为它似乎通过其API“泄漏”了slf4j类型。因此,没有办法将这两个独立的插件彼此隔离开来?我不知道当My3rdPartyLib.My3rdPartyLib_API想要从另一个包导入org.apache.activemq时,如何才能做到这一点。唯一的“解决方案”是修改一个或两个bundle,以便它们都愿意使用相同的slf4j.api包。您没有显示两个捆绑包的清单以允许我建议清单更改。不幸的是,清单太大,stackoverflow不允许我将它们粘贴到这个问题上:(两个清单在“使用”部分都有关于slf4j被导出的多个条目。我不确定如果我删除它们会发生什么。我想应该有一种方法可以让插件共存,而不用我编辑它们的清单(特别是因为我没有编写它们)。RCP/OSGI不支持此功能吗?列在uses指令中并不意味着它是导出的。它只意味着所用包中的类型在导出包的API中可见。从uses中删除可能会导致运行时,当相同类型名称的不同类对象相遇时发生ClassCastException。我想在这里说一些错误由于activemq似乎通过其API“泄漏”了slf4j类型,因此无法将这两个独立的插件彼此隔离?我不知道当My3rdPartyLib.My3rdPartyLib_API想要从另一个捆绑包导入org.apache.activemq时,如何才能做到这一点。唯一的“解决方案”将修改一个或两个捆绑包,以便它们都愿意使用相同的slf4j.api包。您不显示两个捆绑包的清单,以便我建议清单更改。不幸的是,清单太大,stackoverflow不允许我将它们粘贴到这个问题上:(