Adam Morgan
Adam Morgan

Reputation: 495

(mis)understanding osgi bundle dependencies

I'm pretty new to osgi and bndtools, but in the past couple days have managed to get jar->bundle creation working using bnd ant task, plus wrapping of our 3rd party jars as bundles (for those not already defining an 'Export-Package' in the manifest file). I must comment that bndtools seems amazing for doing all the heavy lifting when it comes to exports and imports, so thank you to your hard work on this project!

i've got two issues that maybe you can shed some light on:

1

I'm trying to get the bundles to load in felix and am immediately running into resolution errors. In this basic scenario, we have our in-house bundle called omniquery_common, which uses several 3rd party jars, including gson. when i resolve i get this:

Unable to resolve <<INITIAL>> version=null:
   missing requirement Require[osgi.identity]{}{filter=(osgi.identity=omniquery_common)} [caused by:
   Unable to resolve omniquery_common version=1.0.0.0:
   missing requirement Require[osgi.wiring.package]{}{filter=(&(osgi.wiring.package=com.google.gson)(version>=2.2.0)(!(version>=3.0.0)))}]

To me this says omniquery_common is importing com.google.gson (of a version at least 2.2 and less than 3.0). the gson bundle is exporting version 2.2.4, so this should satisfy its dependency, but is not.

can you help me understand how i am wiring this up wrong?

manifest for omniquery_common:

Manifest-Version: 1.0
Bnd-LastModified: 1442336803995
Bundle-ManifestVersion: 2
Bundle-Name: omniquery_common
Bundle-SymbolicName: omniquery_common
Bundle-Version: 1.0.0.0
Created-By: 1.8.0_40 (Oracle Corporation)
Export-Package: com.radian6.omni.common.osgi;version="1.0.0"
Import-Package: com.google.gson;version="[2.2,3)",com.radian6.omni.commo
 n.util,org.apache.commons.io;version="[1.4,2)",org.apache.commons.lang;
 version="[2.6,3)",org.junit
Private-Package: com.radian6.omni.common.core
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.7))"
Tool: Bnd-2.4.1.201501161923

manifest for gson:

Manifest-Version: 1.0
Export-Package: com.google.gson;version=2.2.4, com.google.gson.annotat
 ions;version=2.2.4, com.google.gson.reflect;version=2.2.4, com.google
 .gson.stream;version=2.2.4, com.google.gson.internal;version=2.2.4, c
 om.google.gson.internal.bind;version=2.2.4
Bundle-ClassPath: .
Built-By: inder
Bundle-Name: Gson
Created-By: Apache Maven 3.0.4
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-Vendor: Google Gson Project
Bundle-ContactAddress: http://code.google.com/p/google-gson/
Bundle-Version: 2.2.4
Build-Jdk: 1.7.0_21
Bundle-ManifestVersion: 2
Bundle-Description: Google Gson library
Bundle-SymbolicName: com.google.gson
Archiver-Version: Plexus Archiver

2

if i alter the order of the bundles in the 'run requirements' list, putting the gson bundle before omniquery_common, i then get

Unable to resolve <<INITIAL>> version=null:
   missing requirement Require[osgi.identity]{}{filter=(osgi.identity=com.google.gson)}

which i find unintuitive - i would have thought the bundle order in that list would not matter...?

Upvotes: 0

Views: 934

Answers (1)

Neil Bartlett
Neil Bartlett

Reputation: 23948

The order of the requirements in the -runrequirements list does matter, because if there is an error early in the list then we don't bother trying to resolve everything below it. That is: once we know that the resolution cannot succeed, we just exit and print the first error we encountered.

The second error message you copied (when you put the GSON requirement first) suggests that you simply don't have the GSON bundle in your repository. Or, it is not in a repository that is visible to the resolver. The filter (osgi.identity=com.google.gson) fails, which means there is no resource with the identity com.google.gson.

This would also explain the first error message from your own omniquery_common bundle. The resolver cannot find any bundle exporting the package com.google.gson, which would make perfect sense if the GSON bundle is not there.

So, look into the repositories you are resolving against and what their indexes contain. If GSON really does appear to be in there, then I will need further info on to figure out the problem.

Incidentally, once you have this working, you shouldn't need to list GSON explicitly at all in -runrequirements. That is the point of the resolver: we will find all your dependencies based on the packages you used.

Upvotes: 0

Related Questions