问题
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