Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Apache Felix OSGi错误:缺少要求OSGi.extender_Java_Maven_Osgi_Apache Felix - Fatal编程技术网

Java Apache Felix OSGi错误:缺少要求OSGi.extender

Java Apache Felix OSGi错误:缺少要求OSGi.extender,java,maven,osgi,apache-felix,Java,Maven,Osgi,Apache Felix,尝试启动捆绑包时出现以下错误: org.osgi.framework.BundleException: Unable to resolve com.example.test [7](R 7.0): missing requirement [com.example.test [7](R 7.0)] osgi.extender; (&(osgi.extender=osgi.component)(version>=1.3.0)(!(version>=2.0.0)))

尝试启动捆绑包时出现以下错误:

org.osgi.framework.BundleException:
  Unable to resolve com.example.test [7](R 7.0):
    missing requirement [com.example.test [7](R 7.0)] osgi.extender; (&(osgi.extender=osgi.component)(version>=1.3.0)(!(version>=2.0.0)))
  Unresolved requirements:
    [[com.example.test [7](R 7.0)] osgi.extender; (&(osgi.extender=osgi.component)(version>=1.3.0)(!(version>=2.0.0)))]
My pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.example</groupId>
    <artifactId>test</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>bundle</packaging>

    <dependencies>
        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>org.osgi.core</artifactId>
            <version>6.0.0</version>
        </dependency>

        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>org.osgi.service.component.annotations</artifactId>
            <version>1.4.0</version>
        </dependency>
    </dependencies>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.felix</groupId>
                    <artifactId>maven-bundle-plugin</artifactId>
                    <version>4.0.0</version>
                    <extensions>true</extensions>
                </plugin>
            </plugins>
        </pluginManagement>

        <plugins>
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <configuration>
                    <instructions>
                        <Export-Package>com.example</Export-Package>
                    </instructions>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
FacadeLocator.java:

package com.example;

import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;

@Component
public class FacadeLocator {
    public static Facade facade;

    @Reference
    public void setFacade(Facade facade) {
        FacadeLocator.facade = facade;
    }
}
我做错了什么


谢谢

您的捆绑包包含一个声明性服务组件--
FacadeLocator
。这意味着您依赖于实现声明性服务的“扩展程序”捆绑包。您需要将该捆绑包与您自己的捆绑包一起部署,以使其正常工作

ApacheFelix的DS实现包的名称为
org.Apache.Felix.scr
,可以下载


您看到的错误消息可以按如下方式解码。
osgi.extender
名称空间中缺少一个需求(扩展程序的名称空间类似于DS)。您需要的特定扩展器是
osgi.component
,版本1.3或更高版本。maven bundle插件在bundle的META-INF/MANIFEST.MF中生成了这个需求,因为它看到bundle中有一个组件。每当一个bundle有需求时,就必须有另一个bundle提供匹配的功能。在本例中,该捆绑包是
org.apache.felix.scr

非常感谢@Martineralecký顺便说一句,将服务引用保存到静态字段是一个非常糟糕的主意!
package com.example;

import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;

@Component
public class FacadeLocator {
    public static Facade facade;

    @Reference
    public void setFacade(Facade facade) {
        FacadeLocator.facade = facade;
    }
}