无法在 Karaf 中加载捆绑包
Posted
技术标签:
【中文标题】无法在 Karaf 中加载捆绑包【英文标题】:Unable to load bundle in Karaf 【发布时间】:2021-04-23 12:54:49 【问题描述】:我正在关注本教程 https://wiki.onosproject.org/display/ONOS/Template+Application+Tutorial 创建一个 CLI 命令,该命令允许我通过意图阻止 OF 开关的接口。我按照此处https://wiki.onosproject.org/display/ONOS/Developer+Quick+Start 的建议使用 Bazel 构建了 ONOS,一切顺利,甚至创建模板应用程序并将其安装到 ONOS 中。现在在 java 类 AppCommand
中,我导入了包 org.onosproject.openflow.controller.OpenFlowController
,在 pom.xml 文件中添加了带有 artifactID 和 groupID onos-of-api-1.6.0 的依赖项,当我重新安装应用程序时会抛出此错误:
Unable to perform operation on application org.foo.app
org.apache.felix.resolver.reason.ReasonException: Unable to resolve root: missing requirement [root] osgi.identity; osgi.identity=foo-app; type=karaf.feature; version="[1.0.0.SNAPSHOT,1.0.0.SNAPSHOT]"; filter:="(&(osgi.identity=foo-app)(type=karaf.feature)(version>=1.0.0.SNAPSHOT)(version<=1.0.0.SNAPSHOT))" [caused by: Unable to resolve foo-app/1.0.0.SNAPSHOT: missing requirement [foo-app/1.0.0.SNAPSHOT] osgi.identity; osgi.identity=org.foo.foo-app; type=osgi.bundle; version="[1.0.0.SNAPSHOT,1.0.0.SNAPSHOT]"; resolution:=mandatory [caused by: Unable to resolve org.foo.foo-app/1.0.0.SNAPSHOT: missing requirement [org.foo.foo-app/1.0.0.SNAPSHOT] osgi.wiring.package; filter:="(&(osgi.wiring.package=org.onosproject.openflow.controller)(version>=1.6.0)(!(version>=2.0.0)))"]]
at org.apache.felix.resolver.Candidates$MissingRequirementError.toException(Candidates.java:1343) ~[?:?]
at org.apache.felix.resolver.ResolverImpl.doResolve(ResolverImpl.java:392) ~[?:?]
at org.apache.felix.resolver.ResolverImpl.resolve(ResolverImpl.java:378) ~[?:?]
at org.apache.felix.resolver.ResolverImpl.resolve(ResolverImpl.java:332) ~[?:?]
at org.apache.karaf.features.internal.region.SubsystemResolver.resolve(SubsystemResolver.java:257) ~[?:?]
at org.apache.karaf.features.internal.service.Deployer.deploy(Deployer.java:393) ~[?:?]
at org.apache.karaf.features.internal.service.FeaturesServiceImpl.doProvision(FeaturesServiceImpl.java:1062) ~[?:?]
at org.apache.karaf.features.internal.service.FeaturesServiceImpl.lambda$doProvisionInThread$13(FeaturesServiceImpl.java:998) ~[?:?]
at java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
at java.lang.Thread.run(Thread.java:834) [?:?]
好像是依赖的版本有问题,但是不明白为什么。
非常感谢您的关注。
【问题讨论】:
【参考方案1】:您从 Karaf 收到的错误消息表明您有一个不满足的依赖项。当您的依赖项在MANIFEST.MF
文件中没有(或不正确)OSGi 元数据时,通常会发生这种情况。您应该打开它并确定您使用的构建系统是否包含它,如果包含,则依赖项是否存在也是 OSGi 化的包。
在这种情况下,请检查具有 org.onosproject.openflow.controller
的 Jar 是否是 OSGi 包 - 它看起来不像。
【讨论】:
以上是关于无法在 Karaf 中加载捆绑包的主要内容,如果未能解决你的问题,请参考以下文章