由于对自身的依赖,在 felix 中加载包失败

Loading bundle in felix fails due to dependency on itself

我显然是白痴,但我看不出问题所在:

我试图在 Karaf 4 M3 中加载一个包,我得到的错误是这个

org.osgi.framework.BundleException: Unable to resolve package-core [50](R 50.0): missing requirement [package-core [50](R 50.0)] osgi.wiring.package; (osgi.wiring.package=bi.package.internal) Unresolved requirements: [[package-core [50](R 50.0)] osgi.wiring.package; (osgi.wiring.package=bi.package.internal)]

我的清单是由 Maven 生成的,如下所示:

Manifest-Version: 1.0
Export-Package: bi.package.core.repository;uses:="bi.package.core.repository.objects";version="4.0.0.SNAPSHOT",bi.package.core.repository.objects;version="4.0.0.SNAPSHOT"
Private-Package: bi.package.internal.*
Built-By: bugg
Tool: Bnd-0.0.255
Bundle-Name: package-core
Created-By: Apache Maven Bundle Plugin
Build-Jdk: 1.7.0_65
Bundle-Version: 4.0.0.SNAPSHOT
Bnd-LastModified: 1435161944129
Bundle-ManifestVersion: 2
Bundle-Activator: bi.package.internal.ExampleActivator
Import-Package: bi.package.core.repository;version="4.0.0.SNAPSHOT",bi.package.core.repository.objects;version="4.0.0.SNAPSHOT",bi.meteorite.internal
Bundle-SymbolicName: package-core

看来它的失败是因为它依赖于它自己?显然那是错误的,所以我哪里搞砸了?

你的问题是这个:

Import-Package: ... bi.meteorite.internal

您导入了一个未导出的包,并且您实际上声明为私有:

Private-Package: bi.package.internal.*

除非真的需要,否则通常最好不要导入导出的包。 如果您导出一个嵌入式依赖项,该依赖项可能会被新版本替换为独立的,则这仅是完全可用的。