Apache felix和Maven - 无法解决:缺少要求osgi.wiring.package

时间:2015-07-29 16:07:02

标签: java eclipse maven

我是Apache Felix的新手。我正在尝试创建一个用于实现configurarion管理员的包。这是我的两个项目:

Activator.java

public void start(BundleContext context) throws Exception {
    Hashtable<String, String> prop = new Hashtable<String, String>();
    prop.put("Message", "Ciao");

    System.out.println("Prova");

    context.registerService(ManagedService.class.getName(), new Configuration(), prop);
}

public void stop(BundleContext context) throws Exception {
    //The service will be unregistered automatically
}

Configuration.java

private String msg = "";

public void updated(Dictionary prop) {
    if(prop == null) {
        System.out.println("Configuration reset");
        msg = null;
    }
    else {
        msg = (String)prop.get("Message");
        System.out.println("Configuration set. Message: " + msg);
    }
}

这些是我的pom.xml依赖项:

<dependency>
    <groupId>org.osgi</groupId>
    <artifactId>org.osgi.compendium</artifactId>
    <version>${org.osgi.compendium.version}</version>
    <scope>compile</scope>
  </dependency>
  <dependency>
    <groupId>org.osgi</groupId>
    <artifactId>org.osgi.core</artifactId>
    <version>${org.osgi.core.version}</version>
    <scope>compile</scope>
  </dependency>

这些是我的pom.xml插件:

<plugin>
    <groupId>org.apache.felix</groupId>
    <artifactId>maven-bundle-plugin</artifactId>
    <version>2.5.3</version>
    <extensions>true</extensions>
    <configuration>
        <supportedProjectTypes>
            <supportedProjectType>jar</supportedProjectType>
            <supportedProjectType>bundle</supportedProjectType>
            <supportedProjectType>war</supportedProjectType>
        </supportedProjectTypes>
        <instructions>
            <Bundle-ManifestVersion>2</Bundle-ManifestVersion>
            <Bundle-Name>${project.name}</Bundle-Name>
            <Bundle-SymbolicName>${project.artifactId};singleton:=true</Bundle-SymbolicName>
            <Bundle-Version>${project.version}</Bundle-Version>
            <Bubdle-Activator>org.apache.felix.conf.Activator</Bubdle-Activator>
            <Bundle-Vendor>FINO</Bundle-Vendor>
            <Import-Package>
                org.osgi.framework,
                org.osgi.service.cm
            </Import-Package>
        </instructions>
    </configuration>
</plugin>

当我在带有终端的apache felix framework 5.0.1中执行我的项目时出现此错误:

org.osgi.framework.BundleException: Unable to resolve org.apache.felix.conf [34](R 34.6): 
    missing requirement [org.apache.felix.conf [34](R 34.6)] osgi.wiring.package; 
        (&(osgi.wiring.package=org.osgi.service.cm)(version>=1.3.0)(!(version>=2.0.0))) 
    Unresolved requirements: [[org.apache.felix.conf [34](R 34.6)] osgi.wiring.package; 
        (&(osgi.wiring.package=org.osgi.service.cm)(version>=1.3.0)(!(version>=2.0.0)))]

我还尝试按照此stackoverflow文章Karaf / Maven - Unable to resolve: missing requirement osgi.wiring.package的解决方案,但它谈论的是apache karaf而不是felix。请帮帮我

更新

这是我的MANIFEST.MF:

    Manifest-Version: 1.0
    Bnd-LastModified: 1438261057801
    Build-Jdk: 1.7.0_79
    Built-By: apache
    Bundle-Description: A maven project that implements apache felix
    Bundle-ManifestVersion: 2
    Bundle-Name: ServerConfig
    Bundle-SymbolicName:tutorials.fino.apachefelix.org.apachefelix.serverco
     nf
    Bundle-Version: 0.0.1.SNAPSHOT
    Created-By: Apache Maven Bundle Plugin
    Export-Package: org.apachefelix.serverconf;version="0.0.1";uses:="org.os
     gi.framework,org.osgi.service.cm"
    Import-Package: org.osgi.framework;version="[1.7,2)",org.osgi.service.cm
     ;version="[1.5,2)"
    Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.5))"
    Tool: Bnd-2.3.0.201405100607

0 个答案:

没有答案