我是Apache Karaf和Osgi的新手。我正在尝试编写并运行一个非常简单的捆绑包。但是我在开始那件捆绑时遇到了这个错误:
错误执行命令:捆绑上的错误执行命令:无法 Resolve Karaf [86](R 86.0):缺失要求[Karaf [86](R 86.0)] OSGI.WIRING.PACKAGE;(osgi.wiring.package =捆绑)未解决 要求:[[KARAF [86](R 86.0)] OSGI.WIRING.PACKAGE; (osgi.wiring.package =捆绑)]
我的pom是:4.0.0
<groupId>com</groupId>
<artifactId>karaf</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>karaf Bundle</name>
<description>
karaf OSGi bundle project.
</description>
<properties>
<maven-bundle-plugin.version>2.5.4</maven-bundle-plugin.version>
<osgi.version>6.0.0</osgi.version>
</properties>
<dependencies>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
<version>${osgi.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>${maven-bundle-plugin.version}</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-Version>${project.version}</Bundle-Version>
<Bundle-Activator>bundle.Activator</Bundle-Activator>
<Export-Package>
bundle*;version=${project.version}
</Export-Package>
<Import-Package>
org.osgi.framework,*
</Import-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
我的清单。mf文件在这里。
> Manifest-Version: 1.0
Bnd-LastModified: 1394131053386
Bundle-Copyright: Copyright (c) OSGi Alliance (2000, 2014). All Rights R
eserved.
Bundle-Description: OSGi Core Release 6, Interfaces and Classes for use
in compiling bundles.
Bundle-License: http://opensource.org/licenses/apache2.0.php; link="http
://www.apache.org/licenses/LICENSE-2.0"; description="Apache License, V
ersion 2.0"
Bundle-ManifestVersion: 2
Bundle-Name: osgi.core
Bundle-SymbolicName: osgi.core
Bundle-Vendor: OSGi Alliance
Bundle-Version: 6.0.0.201403061837
Created-By: 1.6.0_45 (Sun Microsystems Inc.)
DynamicImport-Package: *
Export-Package: org.osgi.dto;version="1.0",org.osgi.resource;version="1.
0",org.osgi.resource.dto;version="1.0";uses:="org.osgi.dto",org.osgi.fr
amework;version="1.8",org.osgi.framework.dto;version="1.8";uses:="org.o
sgi.dto",org.osgi.framework.hooks.bundle;version="1.1";uses:="org.osgi.
framework",org.osgi.framework.hooks.resolver;version="1.0";uses:="org.o
sgi.framework.wiring",org.osgi.framework.hooks.service;version="1.1";us
es:="org.osgi.framework",org.osgi.framework.hooks.weaving;version="1.1"
;uses:="org.osgi.framework.wiring",org.osgi.framework.launch;version="1
.2";uses:="org.osgi.framework",org.osgi.framework.namespace;version="1.
1";uses:="org.osgi.resource",org.osgi.framework.startlevel;version="1.0
";uses:="org.osgi.framework",org.osgi.framework.startlevel.dto;version=
"1.0";uses:="org.osgi.dto",org.osgi.framework.wiring;version="1.2";uses
:="org.osgi.framework,org.osgi.resource",org.osgi.framework.wiring.dto;
version="1.2";uses:="org.osgi.dto,org.osgi.resource.dto",org.osgi.servi
ce.condpermadmin;version="1.1.1";uses:="org.osgi.framework,org.osgi.ser
vice.permissionadmin",org.osgi.service.packageadmin;version="1.2";uses:
="org.osgi.framework",org.osgi.service.permissionadmin;version="1.2",or
g.osgi.service.startlevel;version="1.1";uses:="org.osgi.framework",org.
osgi.service.url;version="1.0",org.osgi.util.tracker;version="1.5.1";us
es:="org.osgi.framework"
Import-Package: javax.security.auth.x500;resolution:=optional
Tool: Bnd-2.2.0.20130927-173453
让我们分解一下:"丢失要求"只是意味着您的捆绑包已安装到OSGI框架中,但它的要求无法满足任何其他捆绑包安装。
尚未解决的要求在命名空间osgi.wiring.package
中,这意味着要求的类型是Java软件包导入,即您在捆绑包的清单中所看到的Import-Package
。换句话说,您的捆绑包会导入一个软件包,而没有其他包装的捆绑包。
最终的钻头 (osgi.wiring.package=bundle)
是 filter ,它表示捆绑包所需的确切包装名称。在这种情况下,您的捆绑包显然会导入一个名为"捆绑"的软件包。
这有点奇怪,这意味着您可能在捆绑包的方式上犯了一个错误。如果您发布有关如何构建此捆绑包的详细信息,这将有所帮助。