Search code examples
osgiequinoxapache-karaf

OSGi - Is it possible to override a bundle's import package version using a fragment?


I have a bundle (jersey-server) that imports a package (org.objectweb.asm) with a resolution of optional and no version specified:

org.objectweb.asm;resolution:=optional

Currently, our application is deployed to Apache Karaf (using the Equinox framework), which exports a new version of this package (org.objectweb.asm), namely version 4.0. The problem I am attempting to solve is that since the jersey-server bundle does not specify a version for the package it is wiring to 4.0. However, the version of jersey-server I am using (1.12) is incompatible with this version. I have a 3.1 version of the package available in the container that I need the jersey-server bundle to wire to.

I have attempted to use a fragment to suit my needs, but it does not appear to be working. I don't fully understand how fragment import-package conflict resolution works in Equinox (or Felix) to know if what I'm trying to do is even possible. Perhaps there is another way?


Solution

  • No, fragments are additive only. I.e. they can add extra imports to their host bundles, but they cannot replace or remove the imports of the host.

    The jersey-server bundle is simply broken and must be fixed.