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

huangapple go评论71阅读模式
英文:

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: 无法解析根:缺少要求 [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))" [由以下原因引起:无法解析 travellinck-osgi/1.0.4:缺少要求 [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 [由以下原因引起:无法解析 com.travellinck.transIT.java-api/1.153.0:缺少要求 [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 和 Java 1.7 构建它。我还尝试过使用 Java 8 构建它,但没有变化。

关于错误消息中的这部分:

由以下原因引起:无法解析 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>
英文:

I have Apache Karaf 4.0.1 running on a Linux Centos 7 server.

I get the following error:

org.osgi.service.resolver.ResolutionException: Unable to resolve root: missing requirement [root] osgi.identity; osgi.identity=travellinck-osgi; type=karaf.feature; version=&quot;[1.0.4,1.0.4]&quot;; filter:=&quot;(&amp;(osgi.identity=travellinck-osgi)(type=karaf.feature)(version&gt;=1.0.4)(version&lt;=1.0.4))&quot; [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=&quot;[1.153.0,1.153.0]&quot;; 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:=&quot;(&amp;(osgi.wiring.package=javax.jws)(version&gt;=1.1.0)(!(version&gt;=2.0.0)))&quot;]]
	at org.apache.felix.resolver.Candidates.populateResource(Candidates.java:314)[org.apache.felix.framework-5.0.1.jar:] 

Any ideas?

I am a novice with apache-karaf/OSGi, so please excuse me if there is pertinent information lacking in this question, I would be glad to add info when suggested.

More info:

I build it using maven with Java1.7. I also tried building it with Java8, but there is no change.

In reference to this part of the error message:

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

In one of the modules, there is the following in the POM:

&lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
&lt;groupId&gt;com.travellinck.integration.vocabulary&lt;/groupId&gt;
&lt;artifactId&gt;com.travellinck.transIT.java-api&lt;/artifactId&gt;
&lt;version&gt;1.153.0&lt;/version&gt;
&lt;name&gt;${bundle.name} ${project.version} [osgi]&lt;/name&gt;
&lt;packaging&gt;bundle&lt;/packaging&gt;
&lt;description&gt;Comprehensive travel services vocabulary&lt;/description&gt;

答案1

得分: 3

在您的错误末尾,它说:“嘿,我错过了这个包: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 子句,列出运行您的 bundle 所需的所有包。

如果您不需要它们,很好!但如果最终确实需要它们,那也没问题!您只需确保安装了版本为 1.1 的 javax.jws 包。

我猜这个包是由 javax.jws-api 导出的,它有一个类似的名称,也是版本 1.1。因此,在您的 karaf 中,您可以执行 bundle:install mvn:javax.jws/javax.jws-api/1.1,理论上,您的 bundle 现在将能够找到所需的包。

为了确保,您可以从 Maven 中央仓库下载该 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 的导出者”。如果您安装它,您的其他 bundle 将能够找到该包。

英文:

In the end of your error, it says : "Hey, I miss this package : javax.jws, and I want it with version >= 1.1 but not superior of 2.0.0"

You fixed that problem by removing all those dependencies.

&lt;dependency&gt;
    &lt;groupId&gt;javax.xml.bind&lt;/groupId&gt;
    &lt;artifactId&gt;jaxb-api&lt;/artifactId&gt;
    &lt;version&gt;2.2.7&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
    &lt;groupId&gt;javax.xml.ws&lt;/groupId&gt;
    &lt;artifactId&gt;jaxws-api&lt;/artifactId&gt;
    &lt;version&gt;2.2.7&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
    &lt;groupId&gt;com.sun.xml.ws&lt;/groupId&gt;
    &lt;artifactId&gt;jaxws-ri&lt;/artifactId&gt;
    &lt;version&gt;2.2.7&lt;/version&gt;
    &lt;type&gt;pom&lt;/type&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
    &lt;groupId&gt;javax.jws&lt;/groupId&gt;
    &lt;artifactId&gt;javax.jws-api&lt;/artifactId&gt;
    &lt;version&gt;1.1&lt;/version&gt;
&lt;/dependency&gt;

Why does it need it ? Because the maven-bundle-plugin that you surely use, scan the dependencies and creates Import-Package clauses in the MANIFEST.MF which list all the packages needed to run your bundle.

If you didn't needed them, good ! But if in the end you needed them, it's not a problem ! You just have to ensure that the package javax.jws is installed with the version 1.1.

I suppose this package is exported by javax.jws-api, which has a similar name and is also at version 1.1. So, in your karaf, you can do bundle:install mvn:javax.jws/javax.jws-api/1.1 and in theory, your bundle will found the required packages now

To be sure, you can download the jar from maven central repo and check in it the META-INF/MANIFEST.MF, which contains :

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

This means "I'm the exporter of javax.jws package at version 1.1.0". If you install it, your other bundle will be able to find that package.

答案2

得分: 0

我通过从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>
英文:

I resolved this by removing these dependencies from the pom:

    &lt;dependency&gt;
        &lt;groupId&gt;javax.xml.bind&lt;/groupId&gt;
        &lt;artifactId&gt;jaxb-api&lt;/artifactId&gt;
        &lt;version&gt;2.2.7&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;javax.xml.ws&lt;/groupId&gt;
        &lt;artifactId&gt;jaxws-api&lt;/artifactId&gt;
        &lt;version&gt;2.2.7&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;com.sun.xml.ws&lt;/groupId&gt;
        &lt;artifactId&gt;jaxws-ri&lt;/artifactId&gt;
        &lt;version&gt;2.2.7&lt;/version&gt;
        &lt;type&gt;pom&lt;/type&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;javax.jws&lt;/groupId&gt;
        &lt;artifactId&gt;javax.jws-api&lt;/artifactId&gt;
        &lt;version&gt;1.1&lt;/version&gt;
    &lt;/dependency&gt;

huangapple
  • 本文由 发表于 2020年10月6日 18:41:37
  • 转载请务必保留本文链接:https://go.coder-hub.com/64224161.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定