Apache Karaf - 无法解析 root:缺少要求 - 原因:无法解析 java-api

Apache Karaf - Unable to resolve root: missing requirement - caused by: Unable to resolve java-api

我在 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的新手,所以如果这个问题缺少相关信息,请原谅,我很乐意在建议时添加信息。

更多信息:

我使用 Maven 和 Java1.7 构建它。我也尝试用 Java8 构建它,但没有任何变化。

参考这部分错误信息:

caused by: Unable to resolve com.travellinck.transIT.java-api/1.153.0

其中一个模块,POM中有如下内容:

<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 central repo 下载 jar 并在其中签入 META-INF/MANIFEST.MF,其中包含:

Export-Package: javax.jws;version="1.1.0",javax.jws.soap;version="1.1.0"

这意味着“我是 javax.jws 版本 1.1.0 包的出口商”。如果您安装它,您的其他包将能够找到该包。