由于多个Joda-Time版本,Karaf无法根据ActiveMQ功能解析bundle



我的捆绑包依赖于Joda-Time 2.x,并通过Karaf(3.0.3)功能文件进行部署。它部署得很好,直到我向activemq-broker(5.11.1) 添加了依赖项并activemq-camelKaraf 提供的功能。我的捆绑包现在无法解析,因为找到了两条指向包"org.joda.time"的路径。一个是我所依赖的版本 2.7,另一个是版本 1.6,它是 ActiveMQ 功能的传递依赖项:

Chain 1:
ch.vivates.ams.pep [152.9]
import: (&(osgi.wiring.package=org.joda.time)(version>=2.7.0)(!(version>=3.0.0)))
|
export: osgi.wiring.package=org.joda.time
joda-time [64.0]
Chain 2:
ch.vivates.ams.pep [152.9]
import: (osgi.wiring.package=org.apache.activemq)
|
export: osgi.wiring.package=org.apache.activemq; uses:=com.thoughtworks.xstream
org.apache.activemq.activemq-osgi [108.0]
import: (&(osgi.wiring.package=com.thoughtworks.xstream)(version>=1.4.0)(!(version>=2.0.0)))
|
export: osgi.wiring.package=com.thoughtworks.xstream; uses:=org.joda.time
org.apache.servicemix.bundles.xstream [118.0]
import: (&(osgi.wiring.package=org.joda.time)(version>=1.6.0)(!(version>=3.0.0)))
|
export: osgi.wiring.package=org.joda.time
joda-time [117.0]

我可以通过在安装功能之前显式启动 Joda-Time 2.7 捆绑包来成功安装我的功能:

bundle:install -s mvn:joda-time/joda-time/2.7

重新启动 Karaf 后,由于同样的原因,我的捆绑包无法启动,我首先必须刷新 Joda-Time 2.7 捆绑包。只有在那之后,我的捆绑包才会开始。

解决这些问题的"适当"方法是什么?尤其是重新启动卡拉夫时的那个?我想我可以通过在我自己的捆绑包中嵌入 Joda Time 的 v2.7 来解决这个问题,但这只是一个黑客。

目前该功能如下所示:

<feature name="name" version="3.0.0-SNAPSHOT" description="description">
<details>details</details>
<feature>http</feature>
<feature>http-whiteboard</feature>
<feature version="5.11.1">activemq-broker-noweb</feature>
<feature version="2.14.1">camel-core</feature>
<feature version="2.14.1">camel-blueprint</feature>
<feature version="2.14.1">camel-netty4-http</feature>
<feature version="2.14.1">camel-http4</feature>
<feature version="2.14.1">camel-jms</feature>
<feature version="5.11.1">activemq-camel</feature>
<bundle dependency="true">mvn:my.package/base/3.0.0-SNAPSHOT</bundle>
<bundle>mvn:my.package/myBundle/3.0.0-SNAPSHOT</bundle>
<bundle>mvn:joda-time/joda-time/2.7</bundle>
<bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.opensaml/2.6.1_3</bundle>
<bundle>mvn:commons-lang/commons-lang/2.6</bundle>
<bundle>wrap:mvn:org.owasp.esapi/esapi/2.0.1</bundle>
<bundle>mvn:org.apache.santuario/xmlsec/1.5.6</bundle>
<bundle>mvn:org.bouncycastle/bcprov-jdk15/1.46</bundle>
<bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-httpclient/3.1_7</bundle>
<bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-collections/3.2.1_3</bundle>
<bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.not-yet-commons-ssl/0.3.11_1</bundle>
<bundle>mvn:org.codehaus.woodstox/woodstox-core-asl/4.4.1</bundle>
<bundle>mvn:org.codehaus.woodstox/stax2-api/3.1.4</bundle>
<bundle>mvn:org.herasaf.xacml.core/herasaf-xacml-core/1.0.0.RELEASE</bundle>
<bundle>mvn:net.sf.ehcache/ehcache/2.9.0</bundle>
<bundle>mvn:commons-codec/commons-codec/1.9</bundle>
<bundle>mvn:commons-io/commons-io/2.4</bundle>
</feature>

编辑:

此问题描述了 Camel Salesforce 组件的相同问题。显然,这是通过将导入的版本范围扩大到 [1.6,3] 来解决的。ActiveMQ 捆绑包应用相同的版本范围,但它仍然会产生问题。

上面的场景是Neil Bartlett在这篇博客文章中描述的问题的变体。由于我无法控制ActiveMQ的直接和传递依赖项,因此我可以看到的唯一选项是

  1. 降级我自己对Joda-Time的依赖,以匹配xstream使用的版本
  2. 在我自己的捆绑包中静态链接/嵌入 Joda-Time 2.7

我选择了选项 2)。

最新更新