两个依赖链OSGI [英] two dependency chains OSGI

查看:239
本文介绍了两个依赖链OSGI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到以下错误:

以文本形式:

Error executing command: Error restarting bundles:
    Unable to start bundle 278: Uses constraint violation. Unable to resolve resource demo-persistence-jpa [demo-persistence-jpa [278](R 278.0)] because it is exposed to package 'javax.persistence' from resources javax.persistence [javax.persistence [248](R 248.0)] and org.apache.geronimo.specs.geronimo-jpa_2.0_spec [org.apache.geronimo.specs.geronimo-jpa_2.0_spec [266](R 266.0)] via two dependency chains.

Chain 1:
demo-persistence-jpa [demo-persistence-jpa [278](R 278.0)]

import: (&(osgi.wiring.package=javax.persistence)(version>=2.1.0))
 |
export: osgi.wiring.package: javax.persistence
javax.persistence [javax.persistence [248](R 248.0)]
Chain 2:
demo-persistence-jpa [demo-persistence-jpa [278](R 278.0)]
import: (osgi.wiring.package=org.hibernate.proxy)
 |
export: osgi.wiring.package=org.hibernate.proxy; uses:=javax.persistence
com.springsource.org.hibernate [com.springsource.org.hibernate [230](R   230.0)]
  import: (&(osgi.wiring.package=javax.persistence)(version>=1.0.0)(!(version>=2.0.0)))
 |
export: osgi.wiring.package: javax.persistence
org.apache.geronimo.specs.geronimo-jpa_2.0_spec   [org.apache.geronimo.specs.geronimo-jpa_2.0_spec [266](R 266.0)] Unresolved   requirements: [[demo-persistence-jpa [278](R 278.0)] osgi.wiring.package; (osgi.wiring.package=org.hibernate.proxy)]

如您所见,问题是我的捆绑包demo-persistence-jpa imports包`javax.persistence,可通过两条链获得,据我所知

as you can see the problem is my bundle demo-persistence-jpa imports the package `javax.persistence which is available via two chains, this I understand

我不明白的地方:

  • 我的捆绑商品进口在version>=2.1.0

org.hibernate.proxy的导入范围为(version>=1.0.0)(!(version>=2.0.0))),因此应该没有问题

org.hibernate.proxy imports within the range (version>=1.0.0)(!(version>=2.0.0))), so there should be no problem

我的捆绑包导入了org.hibernate.proxy

所以应该没有问题,因为我的捆绑包所需的版本与org.hibernate.proxy

so there should be no problem, as the version required by my bundle is not the same as the one required by org.hibernate.proxy

还是我弄错了?

推荐答案

问题是

  • demo-persistence-jpa同时需要javax.persistenceorg.hibernate.proxy.
  • 休眠捆绑包导出org.hibernate.proxy
  • 休眠捆绑包声明为uses:=javax.persistence
  • demo-persistence-jpa needs both javax.persistence and org.hibernate.proxy.
  • hibernate bundle exports org.hibernate.proxy
  • hibernate bundle states it uses:=javax.persistence

对于解析器,这意味着使用hibernate捆绑包中的软件包的任何人都必须连接至与捆绑了cb的javax.persistence完全相同的捆绑包/类加载器.

for the resolver this means that whoever uses packages from hibernate bundle has to be wired to the exact same bundle/classloader providing javax.persistence that hibernate bundle is wired to.

如果运行时无法确保每个对象都连接到不同的bundle/classloders,则从休眠捆绑返回的对象返回javax.persistence对象的那一刻起,您将得到ClassCastException,因为它来自不同的类加载器.

If the runtime din't ensure that and each was wired to different bundles/classloders you would get ClassCastException the moment something from hibernate bundle returns you an object from javax.persistence because it will be coming from different classloader.

在上述情况下,解析器无法确保由于休眠捆绑软件需要javax.persistence版本低于2.0,而demo-persistence-jpa需要版本高于2.1!

In the case above, the resolver can no ensure that because hibernate bundle needs javax.persistence version to be lower than 2.0 and demo-persistence-jpa needs the version to be higher than 2.1!

解决方案是:

  • 使用适用于javax.persistence> = 2.1的较新版本的hibernate(假设有一个版本)
  • 使demo-persistence-jpa导入javax.persistence< 2.1
  • use newer version of hibernate (assuming there is one) that works with javax.persistence >= 2.1
  • make demo-persistence-jpa import javax.persistence < 2.1

这篇关于两个依赖链OSGI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆