问题描述
我在Linux Centos 7服务器上运行了Apache Karaf 4.0.1。
我收到以下错误:
org.osgi.service.resolver.ResolutionException: Unable to resolve root: missing requirement [root] osgi.identity; osgi.identity=travellinck-osgi; type=karaf.feature; version="[1.0.4,1.0.4]"; filter:="(&(osgi.identity=travellinck-osgi)(type=karaf.feature)(version>=1.0.4)(version<=1.0.4))" [caused by: Unable to resolve travellinck-osgi/1.0.4: missing requirement [travellinck-osgi/1.0.4] osgi.identity; osgi.identity=com.travellinck.transIT.java-api; type=osgi.bundle; version="[1.153.0,1.153.0]"; resolution:=mandatory [caused by: Unable to resolve com.travellinck.transIT.java-api/1.153.0: missing requirement [com.travellinck.transIT.java-api/1.153.0] osgi.wiring.package; filter:="(&(osgi.wiring.package=javax.jws)(version>=1.1.0)(!(version>=2.0.0)))"]]
at org.apache.Felix.resolver.Candidates.populateResource(Candidates.java:314)[org.apache.Felix.framework-5.0.1.jar:]
有什么想法吗?
我是apache-karaf / Osgi的新手,所以如果此问题中缺少相关信息,请原谅,我很乐意在建议时添加信息。
更多信息:
我使用带有Java1.7的maven来构建它。我也尝试过使用Java8构建它,但是没有变化。
关于错误消息的这一部分:
caused by: Unable to resolve com.travellinck.transIT.java-api/1.153.0
<modelVersion>4.0.0</modelVersion>
<groupId>com.travellinck.integration.vocabulary</groupId>
<artifactId>com.travellinck.transIT.java-api</artifactId>
<version>1.153.0</version>
<name>${bundle.name} ${project.version} [osgi]</name>
<packaging>bundle</packaging>
<description>Comprehensive travel services vocabulary</description>
解决方法
我通过从pom中删除这些依赖项来解决了这个问题:
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.2.7</version>
</dependency>
<dependency>
<groupId>javax.xml.ws</groupId>
<artifactId>jaxws-api</artifactId>
<version>2.2.7</version>
</dependency>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-ri</artifactId>
<version>2.2.7</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>javax.jws</groupId>
<artifactId>javax.jws-api</artifactId>
<version>1.1</version>
</dependency>
,
在错误的最后,它说:“嘿,我想念这个软件包:javax.jws,我希望它的版本为> = 1.1,但不是2.0.0的上乘版本”
您通过删除所有依赖项解决了该问题。
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.2.7</version>
</dependency>
<dependency>
<groupId>javax.xml.ws</groupId>
<artifactId>jaxws-api</artifactId>
<version>2.2.7</version>
</dependency>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-ri</artifactId>
<version>2.2.7</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>javax.jws</groupId>
<artifactId>javax.jws-api</artifactId>
<version>1.1</version>
</dependency>
为什么需要它?因为您一定要使用maven-bundle-plugin,所以请扫描依赖关系并在MANIFEST.MF中创建Import-Package子句,该子句列出了运行包所需的所有软件包。
如果您不需要它们,那就好!但是,如果最终您需要它们,那不是问题!您只需要确保软件包javax.jws随版本1.1一起安装即可。
我想这个包是由javax.jws-api导出的,它具有相似的名称,并且也是1.1版。因此,您可以在karaf中执行bundle:install mvn:javax.jws/javax.jws-api/1.1
,从理论上讲,您的捆绑包现在将找到所需的包
可以肯定的是,您可以从maven中央存储库下载jar并签入META-INF/MANIFEST.MF
,其中包含:
Export-Package: javax.jws;version="1.1.0",javax.jws.soap;version="1.1.0"
这意味着“我是版本1.1.0的javax.jws软件包的出口商”。如果安装它,则其他捆绑包将能够找到该软件包。