当我尝试在我的OSGi容器中安装一个包时,我看到了这个错误:
Error executing command: Uses constraint violation. Unable to resolve resource com.example.myproject [com.example.myproject/5.0.0.SNAPSHOT] because it is exposed to package 'javax.jms' from resources com.example.resource1 [com.example.resource1/2.0.1] and com.example.resource2 [com.example.resource2/1.1.1] via two dependency chains.
Chain 1:
com.example.myproject [com.example.myproject/5.0.0.SNAPSHOT]
import: (&(osgi.wiring.package=javax.jms)(version>=2.0.0)(!(version>=3.0.0)))
|
export: osgi.wiring.package: javax.jms
com.example.resource1 [com.example.resource1/2.0.1]
Chain 2:
com.example.myproject [com.example.myproject/5.0.0.SNAPSHOT]
import: (&(osgi.wiring.package=com.example.intermediary)(version>=7.2.0)(!(version>=8.0.0)))
|
export: osgi.wiring.package=com.example.intermediary; uses:=javax.jms
com.example.intermediary [com.example.intermediary/7.2.0]
import: (&(osgi.wiring.package=javax.jms)(version>=1.1.0)(!(version>=3.0.0)))
|
export: osgi.wiring.package: javax.jms
com.example.resource2 [com.example.resource2/1.1.1]
据我所知,com.example.resource1导出的包版本可以同时满足这两个链。那么为什么不在这两个地方都使用resource1呢?
发布于 2019-05-16 06:13:51
这是行不通的,因为不能保证从javax.jms
加载一个类只会在捆绑包com.example.resource1
(它导出包的唯一有效版本)结束。因此,在包的某个“连接”状态(它在运行时导入的每个已解析的包,都是可传递的)中,永远不应该有不同版本的包。
这称为类空间一致性,在OSGi Core 7 - 3.7.6 Package Constraints中定义。
一旦核心JVM学会了区分不同版本中的类,这种限制可能就不再需要了-只要其后果是明确的,就可以对其进行控制。
https://stackoverflow.com/questions/56155991
复制相似问题