Karaf 功能安装抛出不受支持 'Bundle-ManifestVersion' 值:1

Karaf Feature install throwing Unsupported 'Bundle-ManifestVersion' value: 1

大家好,我在 karaf 中使用功能安装时遇到以下错误

org.apache.karaf.features.internal.util.MultiException: Error
    at org.apache.karaf.features.internal.download.impl.MavenDownloadManager$MavenDownloader.<init>(MavenDownloadManager.java:84)[9:org.apache.karaf.features.core:4.0.3]
    at org.apache.karaf.features.internal.download.impl.MavenDownloadManager.createDownloader(MavenDownloadManager.java:72)[9:org.apache.karaf.features.core:4.0.3]
    at org.apache.karaf.features.internal.region.Subsystem.downloadBundles(Subsystem.java:358)[9:org.apache.karaf.features.core:4.0.3]
    at org.apache.karaf.features.internal.region.Subsystem.downloadBundles(Subsystem.java:355)[9:org.apache.karaf.features.core:4.0.3]
    at org.apache.karaf.features.internal.region.SubsystemResolver.resolve(SubsystemResolver.java:191)[9:org.apache.karaf.features.core:4.0.3]
    at org.apache.karaf.features.internal.service.Deployer.deploy(Deployer.java:263)[9:org.apache.karaf.features.core:4.0.3]
    at org.apache.karaf.features.internal.service.FeaturesServiceImpl.doProvision(FeaturesServiceImpl.java:1079)[9:org.apache.karaf.features.core:4.0.3]
    at org.apache.karaf.features.internal.service.FeaturesServiceImpl.call(FeaturesServiceImpl.java:975)[9:org.apache.karaf.features.core:4.0.3]
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)[:1.7.0_79]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)[:1.7.0_79]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)[:1.7.0_79]
    at java.lang.Thread.run(Thread.java:745)[:1.7.0_79]
Caused by: java.lang.Exception: Unable to create resource for bundle mvn:org.dt.dummy/Diff-Blueprint/0.0.1-SNAPSHOT
    at org.apache.karaf.features.internal.region.Subsystem.createResource(Subsystem.java:567)[9:org.apache.karaf.features.core:4.0.3]
    at org.apache.karaf.features.internal.region.Subsystem.downloaded(Subsystem.java:376)[9:org.apache.karaf.features.core:4.0.3]
    at org.apache.karaf.features.internal.download.impl.MavenDownloadManager$MavenDownloader.operationComplete(MavenDownloadManager.java:133)[9:org.apache.karaf.features.core:4.0.3]
    at org.apache.karaf.features.internal.download.impl.MavenDownloadManager$MavenDownloader.operationComplete(MavenDownloadManager.java:127)[9:org.apache.karaf.features.core:4.0.3]
    at org.apache.karaf.features.internal.download.impl.DefaultFuture.notifyListener(DefaultFuture.java:344)[9:org.apache.karaf.features.core:4.0.3]
    at org.apache.karaf.features.internal.download.impl.DefaultFuture.notifyListeners(DefaultFuture.java:329)[9:org.apache.karaf.features.core:4.0.3]
    at org.apache.karaf.features.internal.download.impl.DefaultFuture.setValue(DefaultFuture.java:255)[9:org.apache.karaf.features.core:4.0.3]
    at org.apache.karaf.features.internal.download.impl.AbstractDownloadTask.setFile(AbstractDownloadTask.java:61)[9:org.apache.karaf.features.core:4.0.3]
    at org.apache.karaf.features.internal.download.impl.AbstractRetryableDownloadTask.run(AbstractRetryableDownloadTask.java:59)[9:org.apache.karaf.features.core:4.0.3]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)[:1.7.0_79]
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)[:1.7.0_79]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access1(ScheduledThreadPoolExecutor.java:178)[:1.7.0_79]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)[:1.7.0_79]
    ... 3 more
Caused by: org.osgi.framework.BundleException: Unable to build resource for mvn:org.dt.dummy/Diff-Blueprint/0.0.1-SNAPSHOT: Unsupported 'Bundle-ManifestVersion' value: 1
    at org.apache.karaf.features.internal.resolver.ResourceBuilder.build(ResourceBuilder.java:80)[9:org.apache.karaf.features.core:4.0.3]
    at org.apache.karaf.features.internal.resolver.ResourceBuilder.build(ResourceBuilder.java:69)[9:org.apache.karaf.features.core:4.0.3]
    at org.apache.karaf.features.internal.region.Subsystem.createResource(Subsystem.java:565)[9:org.apache.karaf.features.core:4.0.3]
    ... 15 more
Caused by: org.osgi.framework.BundleException: Unsupported 'Bundle-ManifestVersion' value: 1
    at org.apache.karaf.features.internal.resolver.ResourceBuilder.doBuild(ResourceBuilder.java:88)[9:org.apache.karaf.features.core:4.0.3]
    at org.apache.karaf.features.internal.resolver.ResourceBuilder.build(ResourceBuilder.java:78)[9:org.apache.karaf.features.core:4.0.3]
    ... 17 more

feature.xml

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<features xmlns="http://karaf.apache.org/xmlns/features/v1.3.0" name="Diff-Blueprint">
    <feature name="Diff-Blueprint" description="Diff-Blueprint" version="0.0.1.SNAPSHOT">
        <feature prerequisite="true" dependency="false">wrap</feature>
        <bundle>mvn:org.dt.dummy/Diff-Blueprint/0.0.1-SNAPSHOT</bundle>
        <bundle>wrap:mvn:osgi/osgi/3.0.1</bundle>
        <bundle>wrap:mvn:javax.xml/xml/3.1.0</bundle>
        <bundle>wrap:mvn:xmlunit/xmlunit/1.6</bundle>
        <bundle>wrap:mvn:junit/junit/4.11</bundle>
        <bundle>wrap:mvn:org.hamcrest/hamcrest-core/1.3</bundle>
        <bundle>mvn:com.googlecode.json-simple/json-simple/1.1.1</bundle>
        <bundle>wrap:mvn:de.odysseus.staxon/staxon-jackson/1.2</bundle>
        <bundle>mvn:com.fasterxml.jackson.core/jackson-core/2.0.6</bundle>
        <bundle>wrap:mvn:de.odysseus.staxon/staxon/1.2</bundle>
        <bundle>mvn:log4j/log4j/1.2.17</bundle>
        <bundle>mvn:org.codehaus.jackson/jackson-mapper-asl/1.9.13</bundle>
        <bundle>mvn:org.codehaus.jackson/jackson-core-asl/1.9.13</bundle>
        <bundle>wrap:mvn:org.unitils/unitils/2.4</bundle>
        <bundle>wrap:mvn:commons-logging/commons-logging/1.1</bundle>
        <bundle>wrap:mvn:commons-dbcp/commons-dbcp/1.2.2</bundle>
        <bundle>wrap:mvn:commons-pool/commons-pool/1.3</bundle>
        <bundle>wrap:mvn:commons-lang/commons-lang/2.3</bundle>
        <bundle>wrap:mvn:commons-collections/commons-collections/3.2</bundle>
        <bundle>wrap:mvn:ognl/ognl/2.6.9</bundle>
        <bundle>wrap:mvn:ant/ant/1.6.5</bundle>
    </feature>
</features>

显然 Diff-Blueprint 包有 Bundle-ManifestVersion: 1 作为 MANIFEST.MF header。这表明它早于 2005 年发布的 OSGi Release 4.0,因此现代版本的 Karaf 不支持它也就不足为奇了。

所以您必须查看生成该捆绑包的工具。

尝试编辑有问题的包的 MANIFEST.MF 文件,只需将
Bundle-ManifestVersion 的值从 1 改为 2。

我找到了一个解决方案,如果我们包装抛出 Bundle-ManifestVersion: 1 的罐子,那么这将起作用

感谢我在这里复活了一个旧线程,但为了详细说明@Charity 的回答,对于以后发现这个问题的任何人(就像我一样)...

问题是我们正在尝试将 non-OSGi 兼容的包部署到容器。解决方案是 "wrap" 导致问题的捆绑包,方法是使用 OPS4J Wiki 中描述的 Wrap 协议。

JAR 示例

使用 Maven 的简单示例如下所示:

wrap:mvn:commons-logging/commons-logging/1.1

请注意,我们必须在捆绑包前加上 "wrap:" 前缀,仅此而已。有关覆盖清单中定义的设置的更复杂示例,请参阅 wiki。

WAR 例子

以几乎相同的方式部署 non-OSGi 兼容的 WAR 文件,而是使用 "webbundle" URI 处理程序:

webbundle:mvn:com.example/example-web-app/1.0/war