java - Apache Felix OSGi 错误:缺少要求 osgi.extender
问题描述
尝试启动捆绑包时出现此错误:
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)))]
我的 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>
代码:
门面.java:
package com.example;
public interface Facade {}
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
来自您的代码。这意味着您依赖于实现声明式服务的“扩展器”包。您需要将该捆绑包与您自己的捆绑包一起部署才能使其正常工作。
来自 Apache Felix 的 DS 实现包具有该名称org.apache.felix.scr
,可以从 Maven Central下载。
你看到的错误信息可以解码如下。您在命名空间中缺少一个要求osgi.extender
(扩展程序的命名空间类似于 DS)。您需要的特定扩展器是osgi.component
1.3 或更高版本。maven-bundle-plugin 在你的包的 META-INF/MANIFEST.MF 中生成了这个需求,因为它看到你的包中有一个组件。只要一个包有需求,就必须有另一个包提供匹配的能力。在这种情况下,该捆绑包是org.apache.felix.scr
.
推荐阅读
- javascript - 第一次聚焦 textInput 时键盘立即关闭
- c# - 将值添加到 DataGridview 中的特定单元格
- ruby-on-rails - 如何将变量从控制器传递到rails中的部分视图文件?
- python - 如何在 Pandas 数据框中将 ISO-8601 对象转换为 DateTime 格式?
- laravel - 未找到 Laravel Aws\Kinesis\KinesisClient
- c# - FileSystemWatcher() 的文件过滤器
- c# - MVVM WPF:根据所选项目从 DataGridComboBoxColumn 中删除元素
- forms - 当我单击输入登录表单时,应在 ionic 4 中提交
- python-3.x - 为什么在 Ubuntu 19.10 中安装 tensorflow-gpu 后 tensorflow 不工作?
- javascript - Material-table:是否可以默认打开detailsPanel?