大家好,
使用 Kura Linux 模拟器,我正在运行 Kura 文档中的 Hello World 示例 http://eclipse.github.io/kura/dev/deploying-bundles.html#remote-target-device
我设法在本地仿真模式下运行 OSGi 插件,这是 Kura Emulator Linux/java 日志的输出。
21:14:18,036 [Component Resolve Thread] INFO HelloOsgi:15 - Bundle org.eclipse.kura.example.hello_osgi has started!
但是,当我尝试从控制台启动/停止 bundle 时,我只能实现安装步骤。 以下是安装后 Host OSGi 控制台的一些相关输出。
osgi> install file:/home/tihomir/workspace/kura/plugins/org.eclipse.kura.example.hello_osgi_1.0.0.201712111129.jar
Bundle id is 1020
LastModified 1513020115678
Headers Bundle-ManifestVersion = 2
Bundle-Name = Hello World Example with Logger
Bundle-RequiredExecutionEnvironment = JavaSE-1.8
Bundle-SymbolicName = org.eclipse.kura.example.hello_osgi
Bundle-Version = 1.0.0.201712111129
Import-Package = org.eclipse.osgi.framework.console;version="1.0.0",
org.osgi.framework;version="1.3.0",
org.osgi.service.component;version="1.2.2",
org.osgi.service.component.annotations;version="1.2.0";resolution:=optional,
org.osgi.util.tracker;version="1.3.1",org.4j;version="1.7.21"
Manifest-Version = 1.0
Service-Component = OSGI-INF/*.xml
Location file:/home/tihomir/workspace/kura/plugins/org.eclipse.kura.example.hello_osgi_1.0.0.201712111129.jar
State 2
Bundle 1020|Installed | 1|org.eclipse.kura.example.hello_osgi (1.0.0.201712111129)
Version 1.0.0.201712111129
RegisteredServices null
ServicesInUse null
Module osgi.identity; osgi.identity="org.eclipse.kura.example.hello_osgi"; type="osgi.bundle"; version:Version="1.0.0.201712111129" [id=1020]
SymbolicName org.eclipse.kura.example.hello_osgi
BundleContext null
BundleId 1020
osgi> ss
"Framework is launched."
id State Bundle
0 ACTIVE org.eclipse.osgi_3.12.50.v20170928-1321
Fragments=1
997 RESOLVED org.slf4j.api_1.7.2.v20121108-1250
Fragments=5, 998
998 RESOLVED org.slf4j.impl.log4j12_1.7.2.v20131105-2200
Master=997
1020 INSTALLED org.eclipse.kura.example.hello_osgi_1.0.0.201712111129
但是现在,当我尝试激活该 bundle 时,尽管上面的输出显示 org.slf4j 已解决,但我收到以下异常
osgi> start 1020
gogo: BundleException: Could not resolve module: org.eclipse.kura.example.hello_osgi [1020]
Unresolved requirement: Import-Package: org.slf4j; version="1.7.21"
我正在 Debian 9 上运行模拟器。 这也是插件 list
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Hello World Example with Logger
Bundle-SymbolicName: org.eclipse.kura.example.hello_osgi
Bundle-Version: 1.0.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Service-Component: OSGI-INF/*.xml
Import-Package: org.eclipse.osgi.framework.console;version="1.0.0",
org.osgi.framework;version="1.3.0",
org.osgi.service.component;version="1.2.2",
org.osgi.service.component.annotations;version="1.2.0";resolution:=optional,
org.osgi.util.tracker;version="1.3.1",
org.slf4j;version="1.7.21"
已经尝试了我在此处和 Eclipse 论坛上找到的一些检查/修复,但没有任何效果,因此欢迎任何新的建议。
最佳答案
编辑项目的 POM 并降级 SLF4j,因为 Kura 似乎提供 SLF4j v 1.7.2,而您的 bundle 至少需要 v 1.7.21
<小时/>根据 @NeilBartlett 的评论,启动 SLF4j 包不需要解决包的依赖关系。我将这部分答案留在这里作为提醒,以防您没有看到来自 bundle 的任何日志行。
SLF4j 包未启动(ss
显示它们处于 RESOLVED 状态)。尝试使用 start 997 998
启动它们。
关于java - 在 Kura 模拟器中启动 bundle 时 Unresolved 要求 : Import-Package: org. slf4j,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47761126/