简体   繁体   English

未解决的要求:在Kura Emulator中启动捆绑包时,导入包:org.slf4j

[英]Unresolved requirement: Import-Package: org.slf4j when starting bundle in Kura Emulator

Hi everyone, 嗨,大家好,

Using the Kura Linux emulator, I am running the Hello World example from the Kura Documentation http://eclipse.github.io/kura/dev/deploying-bundles.html#remote-target-device 使用Kura Linux模拟器,我正在运行Kura文档http://eclipse.github.io/kura/dev/deploying-bundles.html#remote-target-device中的Hello World示例

I managed to run the OSGi plugin in local emulation mode, here's the output from the Kura Emulator Linux/java log. 我设法在本地仿真模式下运行OSGi插件,这是Kura Emulator Linux / java日志的输出。

21:14:18,036 [Component Resolve Thread] INFO  HelloOsgi:15  - Bundle org.eclipse.kura.example.hello_osgi has started!

However when I try to start/stop the bundle from the console, I only manage to implement the install step. 但是,当我尝试从控制台启动/停止捆绑软件时,我仅设法实现了安装步骤。 Here are some relevant outputs from the Host OSGi console after installation. 安装后,这是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

But now, when I try to activate the bundle, despite the output above showing org.slf4j is resolved, I get the following exception 但是现在,当我尝试激活捆绑包时,尽管上面的输出显示了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"

I am running the emulator on Debian 9. Here's also the plugin manifest 我在Debian 9上运行模拟器。这也是插件清单

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"

Already tried a few checks/fixes that I found here and on the Eclipse forum, but nothing worked, so any fresh suggestions are welcome. 我已经尝试了一些在这里和Eclipse论坛上找到的检查/修复,但是没有任何效果,因此欢迎提出任何新建议。

Edit the POM of your project and downgrade SLF4j, since Kura seems to offer SLF4j v 1.7. 编辑项目的POM并降级SLF4j,因为Kura似乎提供了SLF4j v 1.7。 2 whilst your bundle requires at least v 1.7. 2,而您的捆绑包至少要求v 1.7。 21 21


As per @NeilBartlett's comment starting the SLF4j bundles is not required for your bundle's dependency to resolve. 按照@NeilBartlett的评论,不需要SLF4j捆绑包即可解决捆绑包的依赖性。 I leave here this part of the answer as reminder in the case that you don't see any log line coming from your bundle. 如果您看不到捆绑包中的任何日志行,则在此处保留答案的这一部分,以提醒您。

SLF4j bundles are not started ( ss shows them in RESOLVED state). SLF4j捆绑包未启动( ss显示它们处于已解决状态)。 Try with start 997 998 to start them. 尝试start 997 998开始启动它们。

Your Import-Package ranges look wrong in general. 您的Import-Package范围通常看起来是错误的。 For example you have this: 例如,您有以下内容:

Import-Package: org.slf4j;version="1.7.21"

First: specifying the micro segment (ie the last segment, 21) is unnecessary. 首先:无需指定微片段(即最后一个片段21)。 The micro version indicates bug fixes, performance improvements, documentation changes etc. None of which have any semantic impact on you as a consumer. 微型版本指示错误修复,性能改进,文档更改等。所有这些都不会对您作为消费者产生任何语义上的影响。 Therefore you should just import from version 1.7 because any micro version below that will be compatible with your code. 因此,您应该只从1.7版导入,因为低于该版本的任何微型版本都将与您的代码兼容。

Second: you have no upper bound on your import range! 第二:您的进口范围没有上限! This means you will import from version 1.7.21 or any higher version , up to infinity. 这意味着您将从1.7.21版或更高版本开始导入,直至无限。 So while you are extremely anal about the bottom end of your range, you are fantastically carefree about the upper end! 因此,尽管您对范围的下限极为厌恶,但对上端却无忧无虑! You should limit the range as follows: 您应该限制范围如下:

Import-Package: org.slf4j; version="[1.7,2.0)"

This allows your bundle to import version 1.7 up to but NOT including version 2.0 of Slf4j (if that ever exists). 这使您的捆绑软件可以导入1.7版之前的版本,但不包括Slf4j的2.0版(如果存在)。 This is correct because version 2 would indicate a breaking change in the Slf4j APIs. 这是正确的,因为版本2将指示Slf4j API中的重大更改。

Same advice for all your other imports: 对您所有其他进口产品的建议相同:

Import-Package: org.osgi.framework;version="[1.3, 2.0)",
  org.osgi.service.component;version="[1.2, 2.0)",
  ... etc

If you use bnd or one of its derivative tools to generate your manifest, you won't have to think about any of this and it will all just be correct. 如果您使用bnd或其衍生工具之一来生成清单,则无需考虑其中任何一个,这一切都是正确的。

Thanks @NeilBartlett @AlessandroDaRugna 谢谢@NeilBartlett @AlessandroDaRugna

It turned out that the example was working as expected after all. 事实证明,该示例毕竟按预期运行。 It was a matter of figuring out which console was meant in the documentation, since in Eclipse IDE you can choose between two options. 弄清楚文档中要使用哪个控制台是一个问题,因为在Eclipse IDE中,您可以在两个选项之间进行选择。 The Kura Emulator Linux/java console, the one the instructions apparently had in mind, is not very user friendly and takes some time getting used to. Kura Emulator Linux / java控制台(说明中显然想到的一个)不是非常用户友好,并且需要一些时间来习惯。 The other console, the Host OSGi, I couldn't really it figure out, but it seems to be decoupled from the emulator, maybe a general purpose interface of a kind. 另一个控制台,即Host OSGi,我无法确定,但它似乎与仿真器分离了,也许是一种通用接口。

Again, thank you for the support. 再次感谢您的支持。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 OSGi包错误:org.slf4j的访问限制 - OSGi bundle error : Access restriction for org.slf4j 未解决的要求:导入包:bndtools / osgi中的org.apache.commons.codec.language - Unresolved requirement: Import-Package: org.apache.commons.codec.language in bndtools/osgi 错误:包 org.slf4j 不存在 - error: package org.slf4j does not exist 在Tomcat上为Liferay部署OSGi模块时,“未解决的要求:导入包:javax.ws.rs” - “Unresolved requirement: Import-Package: javax.ws.rs” when deploying OSGi module for Liferay on Tomcat 未解决的要求:导入包:com.google.common.base - Unresolved requirement: Import-Package: com.google.common.base 在MacOS的IDEA中运行bnd结构的应用程序:未解决的要求:导入包:com.apple.eawt - Running bnd-structured app in IDEA on MacOS: Unresolved requirement: Import-Package: com.apple.eawt 未解决的要求:导入包:com.liferay.docs.guestbook.model; 版本=&quot;[1.0.0,1.1.0)&quot;_ - Unresolved requirement: Import-Package: com.liferay.docs.guestbook.model; version="[1.0.0,1.1.0)"_ 如何解决要求:导入包: - How to resolve requirement: Import-Package: 为什么Bytebuddy仪器不能使用org.slf4j类? - Why can't Bytebuddy instrument org.slf4j classes? 春季启动2。Java10。JUnit。 可以从多个模块中访问org.slf4j软件包: <unnamed> ,slf4j.api - Spring boot 2. Java 10. JUnit. The package org.slf4j is accessible from more than one module: <unnamed>, slf4j.api
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM