Reputation: 290
I'm new to OSGi. I am running Apache Felix on Android. I have set the system packages to be exported by the system bundle as below:
/** Packages exported by the system bundle. */
String SYSTEM_PACKAGES =
"org.osgi.framework;version=\"1.6.0\"," +
"org.osgi.framework.launch;version=\"1.0.0\"," +
"org.osgi.framework.wiring;version=\"1.0.0\"," +
"org.osgi.framework.startlevel;version=\"1.0.0\"," +
"org.osgi.framework.hooks.bundle;version=\"1.0.0\"," +
"org.osgi.framework.hooks.resolver;version=\"1.0.0\"," +
"org.osgi.framework.hooks.service;version=\"1.1.0\"," +
"org.osgi.framework.hooks.weaving;version=\"1.0.0\"," +
"org.osgi.service.packageadmin;version=\"1.2.0\"," +
"org.osgi.service.startlevel;version=\"1.1.0\"," +
"org.osgi.service.url;version=\"1.0.0\"," +
"org.osgi.util.tracker;version=\"1.5.0\"";
Map map = new HashMap();
map.put ( "org.osgi.framework.system.packages" , SYSTEM_PACKAGES );
// I set more properties ...
felix = new Felix ( map );
felix.start();
However, when I try to install the ConfigAdmin bundle, it gives a BundleException:
org.osgi.framework.BundleException: Unresolved constraint in bundle
org.apache.felix.configadmin [1]: Unable to resolve 1.0: missing requirement [1.0]
osgi.wiring.package; (&(osgi.wiring.package=org.osgi.framework)(version>=1.4.0)
(!(version>=2.0.0)))
Why is it missing this requirement, when I have exported the org.osgi.framework package from the system bundle at version 1.6.0? I have checked that the system property was correctly set, by doing:
// DEBUG
Toast.makeText ( getApplicationContext() ,
felix.getBundleContext().getProperty ( "org.osgi.framework.system.packages" ) ,
Toast.LENGTH_LONG ).show();
Probably it is a simple mistake on my part. Can someone please help me?
Thanks!
Upvotes: 2
Views: 1321
Reputation: 290
The issue got solved. I was making a mistake while setting the extra packages parameter:
map.put ( "org.osgi.framework.system.packages.extra" , "" );
Felix does not accept the empty string (I had used an empty string initially, thinking I would add package names to it later). When I removed this statement, things worked fine.
As BJ Hargrave said, no need to set the system packages.
Also, we should not pass empty strings as map values, I had not realized that.
Upvotes: 1
Reputation: 9384
Why are you doing this? Felix should automatically export those packages from the systems bundle.
And if you need to export additional packages from the system bundle, beyond those normally exported, use the org.osgi.framework.system.packages.extra
launch configuration property.
Upvotes: 3