无法解析 112.0:缺少要求 [112.0] osgi.wiring.package; (&(osgi.wiring.package=org.osgi.framework)(版本>=1.8.0))

Unable to resolve 112.0: missing requirement [112.0] osgi.wiring.package; (&(osgi.wiring.package=org.osgi.framework)(version>=1.8.0))

我正在 apache Karaf 3.0.3 中创建一个简单的 Echo 服务包,我有我的 Activator class,

package com.company.activator;

import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;

public class Activator implements BundleActivator {

    private static BundleContext context;

    static BundleContext getContext() {
        return context;
    }

    /*
     * (non-Javadoc)
     *
     * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
     */
    public void start(final BundleContext bundleContext) throws Exception {
        Activator.context = bundleContext;
    }

    /*
     * (non-Javadoc)
     *
     * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
     */
    public void stop(final BundleContext bundleContext) throws Exception {
        Activator.context = null;
    }

我可以使用以下 Mannifest 文件通过 eclipse 创建 Bundle

Manifest-Version: 1.0
Private-Package: com.company.activator
Built-By: noushad
Tool: Bnd-0.0.238
Bundle-Name: osgi
Created-By: Apache Maven Bundle Plugin
Build-Jdk: 1.7.0_76
Bundle-Version: 1.0.0
Bnd-LastModified: 1427119505629
Bundle-ManifestVersion: 2
Bundle-Activator: com.company.activator.Activator
Export-Packages: com.company.echo
Bundle-SymbolicName: com.company.osgi
Import-Package: org.osgi.framework;version="1.8"

我还有以下POM文件

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.company</groupId>
    <artifactId>osgi</artifactId>
    <packaging>bundle</packaging>
    <version>0.0.1-SNAPSHOT</version>
    <name>osgi Maven Webapp</name>
    <url>http://maven.apache.org</url>
    <dependencies>
        <dependency>
        <groupId>org.osgi</groupId>
        <artifactId>org.osgi.core</artifactId>
        <version>6.0.0</version>
        </dependency>
    </dependencies>
    <build>
        <finalName>osgi</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <version>1.4.0</version>
                <extensions>true</extensions>
                <configuration>
                    <instructions>
                        <Bundle-SymbolicName>${pom.groupId}.${pom.artifactId}</Bundle-SymbolicName>
                        <Bundle-Name>${pom.artifactId}</Bundle-Name>
                        <Bundle-Version>1.0.0</Bundle-Version>
                        <Private-Package>com.company.activator</Private-Package>
                        <Bundle-Activator>com.company.activator.Activator</Bundle-Activator>
                        <Export-Packages>com.company.echo</Export-Packages>
                        <Import-Package>*</Import-Package>
                    </instructions>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

还有我的EchoClass

package com.company.echo;

public class Echo {

    public String echo(final String string) {
        return string;
    }
}

我在 karaf 3.0.3 上部署此应用程序时遇到以下问题

  1. 当我尝试启动包时得到以下堆栈跟踪

    错误:捆绑包 com.company.osgi [112] 错误 starting/stopping 捆绑包。 (org.osgi.framework.BundleException: 束中未解决的约束 com.company.osgi [112]: 无法解决 112.0: 缺少要求 [112.0] osgi.wiring.package; (&(osgi.wiring.package=org.osgi.framework )(版本>=1.8.0))) org.osgi.framework.BundleException:束中未解决的约束 com.company.osgi [112]:无法解决 112.0:缺少要求 [112.0] osgi.wiring.package; (&(osgi.wiring.package=org.osgi.framework)(版本>=1.8.0)) 在 org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:3974) 在 org.apache.felix.framework.Felix.startBundle(Felix.java:2037) 在 org.apache.felix.framework.Felix.setBundleStartLevel(Felix.java:1483) 在 org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:334) 在 java.lang.Thread.run(Thread.java:745)

有人能帮我弄清楚到底是什么问题吗?

提前致谢..!

我认为 karaf 3 不支持 OSGi Core R6(org.osgi.framework 包版本 1.8)。您应该尝试针对其他版本的 OSGi API.

进行编译