我正在将osgi捆绑软件部署到karaf的多模块maven项目中工作。由于以下错误,我们在测试和生产环境中观察到间歇性的捆绑包启动问题,该问题随后在重新启动karaf容器后得以解决:
Caused by: org.osgi.framework.BundleException: Uses constraint violation. Unable to resolve resource myBundle [myBundle [16](R 16.0)] because it is exposed to package 'javax.el' from resources javax.el-api [javax.el-api [236](R 236.0)] and com.sun.el.javax.el [com.sun.el.javax.el [212](R 212.0)] via two dependency chains.
Chain 1:
myBundle [myBundle [16](R 16.0)]
import: (&(osgi.wiring.package=javax.el)(version>=3.0.0)(!(version>=4.0.0)))
|
export: osgi.wiring.package: javax.el
javax.el-api [javax.el-api [236](R 236.0)]
Chain 2:
myBundle [myBundle [16](R 16.0)]
import: (&(osgi.wiring.package=com.sun.el)(version>=3.0.0)(!(version>=4.0.0)))
|
export: osgi.wiring.package: com.sun.el; uses:=javax.el
export: osgi.wiring.package=javax.el
com.sun.el.javax.el [com.sun.el.javax.el [212](R 212.0)] Unresolved requirements: [[myBundle [16](R 16.0)] osgi.wiring.package; (&(osgi.wiring.package=com.sun.el)(version>=3.0.0)(!(version>=4.0.0)))]
at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:4111)[org.apache.felix.framework-5.4.0.jar:]
at org.apache.felix.framework.Felix.startBundle(Felix.java:2117)[org.apache.felix.framework-5.4.0.jar:]
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:998)[org.apache.felix.framework-5.4.0.jar:]
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:984)[org.apache.felix.framework-5.4.0.jar:]
at org.apache.karaf.features.internal.service.FeaturesServiceImpl.startBundle(FeaturesServiceImpl.java:1286)[10:org.apache.karaf.features.core:4.0.7]
at org.apache.karaf.features.internal.service.Deployer.deploy(Deployer.java:846)[10:org.apache.karaf.features.core:4.0.7]
... 6 more
我经历了这两个相关的SO帖子(Error starting bundle in karaf: "via two dependency chains"和Why are uses constraints violated when both chains end in the same bundle?),但是在我的情况下,我实际上无法确定将javax.el-api
依赖项引入myBundle的位置。我们的项目使用的是Hibernate Validator,它需要使用glassfish jar中的EL软件包,因此这里引入了com.sun.el.javax.el
软件包依赖项。我无法确定从何处引入javax.el-api
依赖关系。我尝试使用下面的maven命令检查依赖关系树,但无济于事。
mvn compile dependency:tree
mvn compile dependency:tree -D:verbose
mvn compile dependency:tree -D:verbose -Dincludes=javax.el
这是为休眠验证器添加的依赖项:
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.el</artifactId>
<version>3.0.1-b08</version>
</dependency>
正在使用的karaf版本是4.0.7
任何帮助将不胜感激。