Joe
Joe

Reputation: 13

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?

Upvotes: 1

Views: 1571

Answers (2)

Achim Nierbeck
Achim Nierbeck

Reputation: 5285

I had a similar issue with pax-web, I created a "workaround" for it:

https://github.com/ops4j/org.ops4j.pax.web/tree/master/pax-web-features/xbean-fragment

it's available also through maven: http://search.maven.org/#artifactdetails%7Corg.ops4j.pax.web%7Cxbean-fragment%7C3.0.0.M2%7Cbundle

Upvotes: 1

Neil Bartlett
Neil Bartlett

Reputation: 23948

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.

Upvotes: 1

Related Questions