i cant figure out why the following happens:
I am running an embedded apache felix from a small android application. I programmatically install 2 bundles after starting the framework, but both never enter the "resolved" state. Thereby the Bundle "MyBundle1" imports "MyBundle2".
This is what Logcat tells me:
05-17 20:21:56.514: ERROR/MainActivity(384): org.osgi.framework.BundleException:
Unresolved constraint in bundle de.xy.MyBundle1 [1]: Unable to resolve 1.11: missing
requirement [1.11] package; (package=de.xy.MyBundle2) [caused by: Unable to resolve 2.0:
missing requirement [2.0] package; (&(package=org.osgi.framework)(version>=1.5.0))]
I totally understand what the error-message says (well...org.osgi.framework in version 1.5+ cant be开发者_如何学Python resolved) but i cant figure out why this happens. Why cant the framework resolve "himself"?! I tried to run the same felix.jar as standalone with the adb shell , and both bundles work. Ofcourse, the felix.jar is up to date (3.2)
Thanks for your advice!
Daniel
FelixSetup
m_configMap = new StringMap(false);
try {
m_cache = File.createTempFile("felix-cache", null);
} catch (IOException ex) {
throw new IllegalStateException(ex);
}
m_cache.delete();
boolean mkdirs = m_cache.mkdirs(); // works (=true)
m_activator = new HostActivator(); // implements BundleActivator
List list = new ArrayList();
list.add(m_activator);
m_configMap.put(FelixConstants.LOG_LEVEL_PROP, "1");
m_configMap.put(BundleCache.CACHE_ROOTDIR_PROP, ".");
m_configMap.put(FelixConstants.SYSTEMBUNDLE_ACTIVATORS_PROP, list);
m_configMap.put(FelixConstants.FRAMEWORK_STORAGE, m_cache.getAbsolutePath());
m_felix = new Felix(m_configMap);
try {
m_felix.start();
} catch (BundleException ex) {
Logger.getLogger(MainActivity.class.getName()).log(Level.SEVERE, null, ex);
}
I dont know if it has something to do with the previous problems:
05-18 08:52:59.149: VERBOSE/out(363): Problem creating boot delegation class loader: java.lang.reflect.InvocationTargetException
05-18 08:52:59.209: VERBOSE/out(363): ERROR: Error parsing system bundle export statement: (java.lang.IllegalArgumentException:A header cannot be an empty string.)
05-18 08:52:59.209: VERBOSE/out(363): java.lang.IllegalArgumentException: A header cannot be an empty string.
I install and start the bundles with
myBundle1= bundleContext.installBundle("file:/data/felix/MyBundle1.jar");
myBundle2= bundleContext.installBundle("file:/data/felix/MyBundle2.jar");
myBundle1.start();
they were previously dx'ed and moved to /data/felix with adb push.
The same code I used in the android-application also works inside a regular java console-app.
The way you build up the framework looks okay to me. You could consider
- replacing the
FRAMEWORK_SYSTEMPACKAGES
by a list that is specific for Android, if your bundles will e.g. be using Activities), or - not using a temp file, but point to some directory you know exists.
We have used 3.0.1 in the past successfully, and I do have the idea that the error message you posted has something to do with it. You could try that version of Felix, and if that works, you may have found a regression in Felix, which you can then report to users@felix.apache.org .
精彩评论