How to deploy Osgi Compendium Services in Karaf 4?

空扰寡人 提交于 2020-01-07 03:05:06

问题


I got this error when I tried to deploy a bundle that uses Compendium service:

Error executing command: Unable to resolve root: missing requirement [root]
...
osgi.wiring.package; filter:="(&(osgi.wiring.package=org.osgi.service.component)(version>=1.1.0)
(!(version>=2.0.0)))"]]

My bundle is configured so it uses:

<dependency>
    <groupId>org.osgi</groupId>
    <artifactId>org.osgi.compendium</artifactId>
    <version>5.0.0</version>
</dependency>

And acording to karaf 4 depts documenation. Osgi Compendium version is 5.0.0. Does this means that I need to provision to karaf compendium jar manually? is there any karaf feature contain Compendium Services?


回答1:


The compendium and core jars contain the OSGi APIs. They are only to be used at build time. Do not install these into OSGi. The core APIs are all implemented by the OSGi framework bundle. The compendium as well as the enterprise API bundles contain too many different APIs to be useful at runtime. If you install them they can cause trouble by conflicting with other API versions installed.

Instead you need to provide a bundle that implements the API. This bundle then either embeds the API package it implements or you additionally need to install an API bundle that contains only this API package.

In you case you need to install the "scr" feature which implements the declarative services spec.




回答2:


I found a quote from Jean-Baptiste Onofré

Hi Bob,

Karaf 3.0.0 already use and ship org.osgi.core and org.osgi.compendium.

So yes, you can use 5.0.0 for core, compendium and enterprise.

Regards JB

Telling that Karaf ships osgi compendium. I had a conflict in my pom.xml after the migration to version 5.0.0 and I didnt notice before.



来源:https://stackoverflow.com/questions/34289193/how-to-deploy-osgi-compendium-services-in-karaf-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!