OSGI缺少需求错误 [英] OSGI missing requirement error

查看:123
本文介绍了OSGI缺少需求错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是OSGI的新手,我正在试图弄清楚如何解决下面的错误

I am new to OSGI and I am trying to figure out how I resolve errors such as the one below

org.osgi.framework.BundleException:未解决的约束bundle org.foo.serviceBundle [253]:无法解析253.0:缺少需求[253.0]包; (&(package = org.slf4j)(version> = 1.6.0)(!(version> = 2.0.0)))

org.osgi.framework.BundleException: Unresolved constraint in bundle org.foo.serviceBundle [253]: Unable to resolve 253.0: missing requirement [253.0] package; (&(package=org.slf4j)(version>=1.6.0)(!(version>=2.0.0)))

我使用了maven原型生成一个bundle并在我的Activator类中添加了一些简单的slf4j日志记录。我也使用maven bundle插件如下:

I used a maven archetype to generate a bundle and added some simple slf4j logging to my Activator class. I am also using the maven bundle plugin as follows:

        <plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <version>2.2.0</version>
            <extensions>true</extensions>
            <configuration>
                <instructions>
                    <Bundle-Activator>org.shoppingsite.Activator</Bundle-Activator>
                </instructions>
            </configuration>
        </plugin>

我尝试过其他组合,我得到一个或另一个无法解析的包。我正在尝试将捆绑包部署到GlassFish appserver上。任何帮助将不胜感激

I have tried other combinations and I get one package or the other that is not resolvable. I am trying to deploy the bundle onto GlassFish appserver. Any help will be appreciated

谢谢

推荐答案

这通常意味着你错过了一个导出org.slf4j的包。这是整个工作流程:

This usually means that you're missing a bundle that exports org.slf4j. Here's the whole workflow:


  • maven-bundle-plugin将确保您自己的项目清单导入org.slf4j(从你需要它。)

  • The maven-bundle-plugin will make sure that your own project's manifest imports org.slf4j (since you need it).

项目POM中的maven依赖项将确保下载slf4j工件

The maven dependencies in your project's POM will make sure that the slf4j artifact is downloaded

然后有两件事可能出错:

Then 2 things can go wrong:


  • 编译失败,找不到slf4j工件(但我想你已经注意到了)

  • either your compilation failed and the slf4j artifact wasn't found (but I suppose you'd have noticed that)

或你下载的slf4工件没有清单或者不是出口org.slf4j。要查看它,只需查看org.slf4j包的清单。如果你在像eclipse这样的IDE中直接运行东西,你可能需要检查$ HOME / .m2 /而不是找到工件。

or the slf4 artifact you downloaded does not have a Manifest or is not exporting org.slf4j. To check it out, simply look into the manifest of the org.slf4j bundle. If you are running things directly in an IDE like eclipse, you might want to check in $HOME/.m2/ instead to find the artifact.

如果您的工件没有正确的清单,您必须找到一些其他仓库,您可以从中获取适当的捆绑,或者修改您获得的仓库并将其安装在您当地的存储库(并将其部署在本地maven包存储库(例如nexus),如果有的话)

If your artifact doesn't have a proper manifest, you'll have to either find some other repo you can get a proper bundle from, or modify the one you're getting and installing it on your local repository (and deploying it on your local maven bundle repository (e.g. nexus) if you have one)

最后一件事:考虑使用maven-scr插件而不是直接定义激活者和服务发现。当我开始使用OSGi时,我希望我知道这一点!

Last little thing: consider using the maven-scr plugin instead of directly defining activators and service discovery. I wish I had known that when I started with OSGi!

这篇关于OSGI缺少需求错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆