You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "Jackson, Bruce" <br...@qualcomm.com> on 2010/04/28 19:41:46 UTC

org.osgi.framework.system.packages and Felix embedded in Android

Hi All

I have Felix embedded into an Android app, and I'm trying to export the
packages from the Android environment (e.g. android, android.app, etc) into
Felix.

I have a couple of questions: first, can I still use the pre-4.2
constructor:

Felix felix = new Felix(Properties props);

...and if I do so passing in a properties file which contains a
semicolon-seperated list of packages as per the attached, should I see this
working properly?

Felix starts ok, but when I try to deploy any bundles to it (for example a
dexified org.apache.log4j) I get a message fro the debugger when I call:

BundleContent bc = felix.getBundleContent();
bc.installBundle(name, inputStream);

04-28 18:31:45.716: ERROR/SkiftaService(6274): Unresolved constraint in
bundle org.apache.log4j [1]: package; (package=javax.xml.parsers)

...which seems to suggest that it can't find the package.

Any ideas?

Thanks

Bruce


Re: org.osgi.framework.system.packages and Felix embedded in Android

Posted by "Richard S. Hall" <he...@ungoverned.org>.
On 4/29/10 12:30, Karl Pauls wrote:
> It should work, can you try to add a
>
> ; \
>   version=\"1.6.0\"
>
> to the end of your package list? i.e.,
>
>   org.xml.sax.ext; \
>   org.xml.sax.helpers; \
>   version=\"1.6.0\"
>    

Why might this be necessary? I just noticed that default.properties 
included such a line for JRE 1.6 when I updated to follow the new JRE 
package version numbering scheme (i.e., 0.0.0.<ee>)...since it was the 
only version number like that out of all the other properties, I removed 
the escapes. Do they need to be there for Android?

-> richard

>
> regards,
>
> Karl
>
> On Wed, Apr 28, 2010 at 7:41 PM, Jackson, Bruce<br...@qualcomm.com>  wrote:
>    
>> Hi All
>>
>> I have Felix embedded into an Android app, and I'm trying to export the
>> packages from the Android environment (e.g. android, android.app, etc) into
>> Felix.
>>
>> I have a couple of questions: first, can I still use the pre-4.2
>> constructor:
>>
>> Felix felix = new Felix(Properties props);
>>
>> ...and if I do so passing in a properties file which contains a
>> semicolon-seperated list of packages as per the attached, should I see this
>> working properly?
>>
>> Felix starts ok, but when I try to deploy any bundles to it (for example a
>> dexified org.apache.log4j) I get a message fro the debugger when I call:
>>
>> BundleContent bc = felix.getBundleContent();
>> bc.installBundle(name, inputStream);
>>
>> 04-28 18:31:45.716: ERROR/SkiftaService(6274): Unresolved constraint in
>> bundle org.apache.log4j [1]: package; (package=javax.xml.parsers)
>>
>> ...which seems to suggest that it can't find the package.
>>
>> Any ideas?
>>
>> Thanks
>>
>> Bruce
>>
>>
>>      
>
>
>    

Re: org.osgi.framework.system.packages and Felix embedded in Android

Posted by "Richard S. Hall" <he...@ungoverned.org>.
On 4/30/10 6:30, Jackson, Bruce wrote:
> Actually, the problem is one of syntax, apparently. When you pass in the
> Properties object, the value against the key that was read from the file
> attached (i.e. the standard form of these files) it doesn't work.
>
> The list needs to be comma separated with no additional CR LF characters or
> the parser doesn't do the right thing.
>
> Clearly there must be some form of pre-parsing going on to handle the
> "standard" package lists in Felix.
>    

I don't think so, we just use Properties.load() to load them...the only 
processing is for variable substitution.

-> richard

>
> On 29/04/2010 17:30, "Karl Pauls"<ka...@gmail.com>  wrote:
>
>    
>> It should work, can you try to add a
>>
>> ; \
>>   version=\"1.6.0\"
>>
>> to the end of your package list? i.e.,
>>
>>   org.xml.sax.ext; \
>>   org.xml.sax.helpers; \
>>   version=\"1.6.0\"
>>
>>
>> regards,
>>
>> Karl
>>
>> On Wed, Apr 28, 2010 at 7:41 PM, Jackson, Bruce<br...@qualcomm.com>  wrote:
>>      
>>> Hi All
>>>
>>> I have Felix embedded into an Android app, and I'm trying to export the
>>> packages from the Android environment (e.g. android, android.app, etc) into
>>> Felix.
>>>
>>> I have a couple of questions: first, can I still use the pre-4.2
>>> constructor:
>>>
>>> Felix felix = new Felix(Properties props);
>>>
>>> ...and if I do so passing in a properties file which contains a
>>> semicolon-seperated list of packages as per the attached, should I see this
>>> working properly?
>>>
>>> Felix starts ok, but when I try to deploy any bundles to it (for example a
>>> dexified org.apache.log4j) I get a message fro the debugger when I call:
>>>
>>> BundleContent bc = felix.getBundleContent();
>>> bc.installBundle(name, inputStream);
>>>
>>> 04-28 18:31:45.716: ERROR/SkiftaService(6274): Unresolved constraint in
>>> bundle org.apache.log4j [1]: package; (package=javax.xml.parsers)
>>>
>>> ...which seems to suggest that it can't find the package.
>>>
>>> Any ideas?
>>>
>>> Thanks
>>>
>>> Bruce
>>>
>>>
>>>        
>>
>>      
>    

Re: org.osgi.framework.system.packages and Felix embedded in Android

Posted by Karl Pauls <ka...@gmail.com>.
What version of felix are you using?

If you are using felix 2.0.5, can you send me your project in private
(or make it available somewhere)?

regards,

Karl

On Fri, Apr 30, 2010 at 6:14 PM, Jackson, Bruce <br...@qualcomm.com> wrote:
> Yes, I'm aware of that. What I meant was that I've seen that it works on
> Felix releases with the framework version set to 1.2, but I can't get this
> working with the current release.
>
>
> On 30/04/2010 17:03, "Richard S. Hall" <he...@ungoverned.org> wrote:
>
>> On 4/30/10 9:50, Jackson, Bruce wrote:
>>> I've added the lines:
>>>
>>> // calculate the export packages list from the environment
>>>
>>> config.put("org.osgi.framework.system.packages",
>>> ANDROID_FRAMEWORK_PACKAGES);
>>> config.put("org.osgi.framework.bundle.parent", "app");
>>> config.put("felix.log.level", "1");
>>>
>>> and tried this with app, framework, boot and also ext, but I get the same
>>> result I'm afraid. I've certainly seen out on the web that people have done
>>> with with almost identical code on earlier version of Felix (I can't be sure
>>> of the exact Felix version, but the org.osgi.framework version was set to
>>> 1.2) but is it possible that has become broken in recent releases?
>>>
>>
>> That is the version of the OSGi spec, check in the
>> org.apache.felix.framework.Felix.properties file...
>>
>> -> richard
>>
>>> Thanks
>>>
>>> Bruce
>>>
>>> On 30/04/2010 13:34, "Karl Pauls"<ka...@gmail.com>  wrote:
>>>
>>>
>>>>   In case you have problems on android not finding classes that you are
>>>> making available via the system bundle, make sure you set the
>>>> org.osgi.framework.bundle.parent property to the correct value (either
>>>> app or framework, depends). i.e.,
>>>>
>>>> org.osgi.framework.bundle.parent=app
>>>>
>>>> or
>>>>
>>>> org.osgi.framework.bundle.parent=framework
>>>>
>>>> that should make it work.
>>>>
>>>> regards,
>>>>
>>>> Karl
>>>>
>>>> On Fri, Apr 30, 2010 at 1:38 PM, Jackson, Bruce<br...@qualcomm.com>  wrote:
>>>>
>>>>> As a continuation to this mini-saga, I now have the initial problem (i.e.
>>>>> bundle resolution) fixed with the code below. When I add bundles to the
>>>>> running Felix framework, the resolve correctly, and start as long as their
>>>>> activator does not try to load any of the classes found in
>>>>> ANDROID_FRAMEWORK_PACKAGES, such as android.util.Log. If they do, I get a
>>>>> ClassNotFoundException:
>>>>>
>>>>> 04-30 12:36:25.788: DEBUG/dalvikvm(16018): Making a copy of
>>>>> Lcom/skifta/android/mediaserver/AndroidTestImpl;.test4 code (68 bytes)
>>>>> 04-30 12:36:25.798: WARN/System.err(16018):
>>>>> org.osgi.framework.BundleException: Activator start error in bundle
>>>>> com.skifta.booster.cdir [4].
>>>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>>>> org.apache.felix.framework.Felix.activateBundle(Felix.java:1807)
>>>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>>>> org.apache.felix.framework.Felix.startBundle(Felix.java:1682)
>>>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>>>> org.apache.felix.framework.BundleImpl.start(BundleImpl.java:905)
>>>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>>>> org.apache.felix.framework.BundleImpl.start(BundleImpl.java:892)
>>>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>>>> com.skifta.android.client.SkiftaService.startOSGi(SkiftaService.java:401)
>>>>> ....
>>>>> 04-30 12:36:25.798: WARN/System.err(16018): Caused by:
>>>>> java.lang.NoClassDefFoundError: android.util.Log
>>>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>>>> com.skifta.android.mediaserver.AndroidTestImpl.test1(AndroidTestImpl.java:3
>>>>> 3)
>>>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>>>> com.skifta.booster.cdir.Activator.start(Activator.java:43)
>>>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>>>> org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.ja
>>>>> va
>>>>> :661)
>>>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>>>> org.apache.felix.framework.Felix.activateBundle(Felix.java:1760)
>>>>> 04-30 12:36:25.798: WARN/System.err(16018):     ... 17 more
>>>>>
>>>>>
>>>>> Any idea why the classloader is not allowing bundles I start to see the
>>>>> classes in the packages exported by the framework?
>>>>>
>>>>> private static final String ANDROID_FRAMEWORK_PACKAGES =
>>>>> ("org.osgi.framework; version=1.4.0," +
>>>>>             "org.osgi.service.packageadmin; version=1.2.0," +
>>>>>             "org.osgi.service.startlevel; version=1.0.0," +
>>>>>             "org.osgi.service.url; version=1.0.0," +
>>>>>             "org.osgi.util.tracker," +
>>>>>             "android; " +
>>>>>             "android.app;" +
>>>>>             "android.content;" +
>>>>>             "android.database;" +
>>>>>             "android.database.sqlite;" +
>>>>>             "android.graphics; " +
>>>>>             "android.graphics.drawable; " +
>>>>>             "android.graphics.glutils; " +
>>>>>             "android.hardware; " +
>>>>>             "android.location; " +
>>>>>             "android.media; " +
>>>>>             "android.net; " +
>>>>>             "android.net.wifi; " +
>>>>>             "android.opengl; " +
>>>>>             "android.os; " +
>>>>>             "android.provider; " +
>>>>>             "android.sax; " +
>>>>>             "android.speech.recognition; " +
>>>>>             "android.telephony; " +
>>>>>             "android.telephony.gsm; " +
>>>>>             "android.text; " +
>>>>>             "android.text.method; " +
>>>>>             "android.text.style; " +
>>>>>             "android.text.util; " +
>>>>>             "android.util; " +
>>>>>             "android.view; " +
>>>>>             "android.view.animation; " +
>>>>>             "android.webkit; " +
>>>>>             "android.widget; " +
>>>>>             "com.google.android.maps; " +
>>>>>             "com.google.android.xmppService; " +
>>>>>             "javax.crypto; " +
>>>>>             "javax.crypto.interfaces; " +
>>>>>             "javax.crypto.spec; " +
>>>>>             "javax.microedition.khronos.opengles; " +
>>>>>             "javax.net; " +
>>>>>             "javax.net.ssl; " +
>>>>>             "javax.security.auth; " +
>>>>>             "javax.security.auth.callback; " +
>>>>>             "javax.security.auth.login; " +
>>>>>             "javax.security.auth.x500; " +
>>>>>             "javax.security.cert; " +
>>>>>             "javax.sound.midi; " +
>>>>>             "javax.sound.midi.spi; " +
>>>>>             "javax.sound.sampled; " +
>>>>>             "javax.sound.sampled.spi; " +
>>>>>             "javax.sql; " +
>>>>>             "javax.xml.parsers; " +
>>>>>             "junit.extensions; " +
>>>>>             "junit.framework; " +
>>>>>             "org.apache.commons.codec; " +
>>>>>             "org.apache.commons.codec.binary; " +
>>>>>             "org.apache.commons.codec.language; " +
>>>>>             "org.apache.commons.codec.net; " +
>>>>>             "org.apache.commons.httpclient; " +
>>>>>             "org.apache.commons.httpclient.auth; " +
>>>>>             "org.apache.commons.httpclient.cookie; " +
>>>>>             "org.apache.commons.httpclient.methods; " +
>>>>>             "org.apache.commons.httpclient.methods.multipart; " +
>>>>>             "org.apache.commons.httpclient.params; " +
>>>>>             "org.apache.commons.httpclient.protocol; " +
>>>>>             "org.apache.commons.httpclient.util; " +
>>>>>             "org.json; " +
>>>>>             "org.w3c.dom; " +
>>>>>             "org.xml.sax; " +
>>>>>             "org.xml.sax.ext; " +
>>>>>             "org.xml.sax.helpers; " +
>>>>>             "version=1.6.0");
>>>>>
>>>>> Properties config = System.getProperties();
>>>>> config.put("org.osgi.framework.startlevel.beginning",
>>>>> Integer.toString(SkiftaService.SKIFTA_START_LEVEL));
>>>>> config.put("org.osgi.framework.storage.clean", "onFirstInit");
>>>>>
>>>>> // make sure the OSGi cache dir is set to something sensible
>>>>>
>>>>> File cacheDir = this.getDir("osgi.cache", Context.MODE_PRIVATE);
>>>>> Log.d(TAG, "setting osgi cache location to: " +
>>>>> cacheDir.getAbsolutePath());
>>>>> config.put("org.osgi.framework.storage", cacheDir.getAbsolutePath());
>>>>>
>>>>>
>>>>> // calculate the export packages list from the environment
>>>>>
>>>>> String sysPackages =
>>>>> bootProps.getProperty("org.osgi.framework.system.packages.extra");
>>>>> config.put("org.osgi.framework.system.packages",
>>>>> ANDROID_FRAMEWORK_PACKAGES);
>>>>> config.put("felix.log.level", "1");
>>>>>
>>>>> // Now create an instance of the framework with
>>>>> // our configuration properties.
>>>>>
>>>>> Log.d(TAG, "Starting Felix...");
>>>>> felix = new Felix(config);
>>>>>
>>>>> // Now start Felix instance.
>>>>>
>>>>> felix.start();
>>>>>
>>>>>
>>>>> On 30/04/2010 11:30, "Bruce Jackson"<br...@qualcomm.com>  wrote:
>>>>>
>>>>>
>>>>>> Actually, the problem is one of syntax, apparently. When you pass in the
>>>>>> Properties object, the value against the key that was read from the file
>>>>>> attached (i.e. the standard form of these files) it doesn't work.
>>>>>>
>>>>>> The list needs to be comma separated with no additional CR LF characters
>>>>>> or
>>>>>> the parser doesn't do the right thing.
>>>>>>
>>>>>> Clearly there must be some form of pre-parsing going on to handle the
>>>>>> "standard" package lists in Felix.
>>>>>>
>>>>>>
>>>>>> On 29/04/2010 17:30, "Karl Pauls"<ka...@gmail.com>  wrote:
>>>>>>
>>>>>>
>>>>>>> It should work, can you try to add a
>>>>>>>
>>>>>>> ; \
>>>>>>>   version=\"1.6.0\"
>>>>>>>
>>>>>>> to the end of your package list? i.e.,
>>>>>>>
>>>>>>>   org.xml.sax.ext; \
>>>>>>>   org.xml.sax.helpers; \
>>>>>>>   version=\"1.6.0\"
>>>>>>>
>>>>>>>
>>>>>>> regards,
>>>>>>>
>>>>>>> Karl
>>>>>>>
>>>>>>> On Wed, Apr 28, 2010 at 7:41 PM, Jackson, Bruce<br...@qualcomm.com>
>>>>>>> wrote:
>>>>>>>
>>>>>>>> Hi All
>>>>>>>>
>>>>>>>> I have Felix embedded into an Android app, and I'm trying to export the
>>>>>>>> packages from the Android environment (e.g. android, android.app, etc)
>>>>>>>> into
>>>>>>>> Felix.
>>>>>>>>
>>>>>>>> I have a couple of questions: first, can I still use the pre-4.2
>>>>>>>> constructor:
>>>>>>>>
>>>>>>>> Felix felix = new Felix(Properties props);
>>>>>>>>
>>>>>>>> ...and if I do so passing in a properties file which contains a
>>>>>>>> semicolon-seperated list of packages as per the attached, should I see
>>>>>>>> this
>>>>>>>> working properly?
>>>>>>>>
>>>>>>>> Felix starts ok, but when I try to deploy any bundles to it (for example
>>>>>>>> a
>>>>>>>> dexified org.apache.log4j) I get a message fro the debugger when I call:
>>>>>>>>
>>>>>>>> BundleContent bc = felix.getBundleContent();
>>>>>>>> bc.installBundle(name, inputStream);
>>>>>>>>
>>>>>>>> 04-28 18:31:45.716: ERROR/SkiftaService(6274): Unresolved constraint in
>>>>>>>> bundle org.apache.log4j [1]: package; (package=javax.xml.parsers)
>>>>>>>>
>>>>>>>> ...which seems to suggest that it can't find the package.
>>>>>>>>
>>>>>>>> Any ideas?
>>>>>>>>
>>>>>>>> Thanks
>>>>>>>>
>>>>>>>> Bruce
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>
>>>>
>>>
>
>



-- 
Karl Pauls
karlpauls@gmail.com

Re: Possible bug in ModuleImpl (was Re: org.osgi.framework.system.packages and Felix embedded in Android)

Posted by Karl Pauls <ka...@gmail.com>.
This is not a bug. It is just something that doesn't work on android
but we do handle it correctly. The only result should be that you see
a warning in the log but it shouldn't have any negative impact.

regards,

Karl

On Fri, Apr 30, 2010 at 7:49 PM, Jackson, Bruce <br...@qualcomm.com> wrote:
> I've now followed the Felix code through to the source of this problem which appears to be in ModuleImpl:
>
> static
>    {
>        ClassLoader cl = null;
>        try
>        {
>            Constructor ctor = m_secureAction.getDeclaredConstructor(
>                SecureClassLoader.class, new Class[] { ClassLoader.class });
>            m_secureAction.setAccesssible(ctor);
>            cl = (ClassLoader) m_secureAction.invoke(ctor, new Object[] { null });
>        }
>        catch (Throwable ex)
>        {
>            // On Android we get an exception if we set the parent class loader
>            // to null, so we will work around that case by setting the parent
>            // class loader to the system class loader in getClassLoader() below.
>            cl = null;
>            System.err.println("Problem creating boot delegation class loader: " + ex);
>            ex.printStackTrace();
>        }
>        m_defBootClassLoader = cl;
>    }
>
> This seems to be trying to create a new instance of SecureClassLoader, which is failing because SecureClassLoader doesn’t have any public constructor. This is therefore throwing an InvocationTargetException and is, I believe responsible for the problem I’m seeing. Has this been reported as a bug, does anyone know?
>
> Thanks
>
> Bruce
>
> On 30/04/2010 17:14, "Bruce Jackson" <br...@qualcomm.com> wrote:
>
>> Yes, I'm aware of that. What I meant was that I've seen that it works on
>> Felix releases with the framework version set to 1.2, but I can't get this
>> working with the current release.
>>
>>
>> On 30/04/2010 17:03, "Richard S. Hall" <he...@ungoverned.org> wrote:
>>
>>> On 4/30/10 9:50, Jackson, Bruce wrote:
>>>> I've added the lines:
>>>>
>>>> // calculate the export packages list from the environment
>>>>
>>>> config.put("org.osgi.framework.system.packages",
>>>> ANDROID_FRAMEWORK_PACKAGES);
>>>> config.put("org.osgi.framework.bundle.parent", "app");
>>>> config.put("felix.log.level", "1");
>>>>
>>>> and tried this with app, framework, boot and also ext, but I get the same
>>>> result I'm afraid. I've certainly seen out on the web that people have done
>>>> with with almost identical code on earlier version of Felix (I can't be sure
>>>> of the exact Felix version, but the org.osgi.framework version was set to
>>>> 1.2) but is it possible that has become broken in recent releases?
>>>>
>>>
>>> That is the version of the OSGi spec, check in the
>>> org.apache.felix.framework.Felix.properties file...
>>>
>>> -> richard
>>>
>>>> Thanks
>>>>
>>>> Bruce
>>>>
>>>> On 30/04/2010 13:34, "Karl Pauls"<ka...@gmail.com>  wrote:
>>>>
>>>>
>>>>>   In case you have problems on android not finding classes that you are
>>>>> making available via the system bundle, make sure you set the
>>>>> org.osgi.framework.bundle.parent property to the correct value (either
>>>>> app or framework, depends). i.e.,
>>>>>
>>>>> org.osgi.framework.bundle.parent=app
>>>>>
>>>>> or
>>>>>
>>>>> org.osgi.framework.bundle.parent=framework
>>>>>
>>>>> that should make it work.
>>>>>
>>>>> regards,
>>>>>
>>>>> Karl
>>>>>
>>>>> On Fri, Apr 30, 2010 at 1:38 PM, Jackson, Bruce<br...@qualcomm.com>
>>>>> wrote:
>>>>>
>>>>>> As a continuation to this mini-saga, I now have the initial problem (i.e.
>>>>>> bundle resolution) fixed with the code below. When I add bundles to the
>>>>>> running Felix framework, the resolve correctly, and start as long as their
>>>>>> activator does not try to load any of the classes found in
>>>>>> ANDROID_FRAMEWORK_PACKAGES, such as android.util.Log. If they do, I get a
>>>>>> ClassNotFoundException:
>>>>>>
>>>>>> 04-30 12:36:25.788: DEBUG/dalvikvm(16018): Making a copy of
>>>>>> Lcom/skifta/android/mediaserver/AndroidTestImpl;.test4 code (68 bytes)
>>>>>> 04-30 12:36:25.798: WARN/System.err(16018):
>>>>>> org.osgi.framework.BundleException: Activator start error in bundle
>>>>>> com.skifta.booster.cdir [4].
>>>>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>>>>> org.apache.felix.framework.Felix.activateBundle(Felix.java:1807)
>>>>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>>>>> org.apache.felix.framework.Felix.startBundle(Felix.java:1682)
>>>>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>>>>> org.apache.felix.framework.BundleImpl.start(BundleImpl.java:905)
>>>>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>>>>> org.apache.felix.framework.BundleImpl.start(BundleImpl.java:892)
>>>>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>>>>> com.skifta.android.client.SkiftaService.startOSGi(SkiftaService.java:401)
>>>>>> ....
>>>>>> 04-30 12:36:25.798: WARN/System.err(16018): Caused by:
>>>>>> java.lang.NoClassDefFoundError: android.util.Log
>>>>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>>>>> com.skifta.android.mediaserver.AndroidTestImpl.test1(AndroidTestImpl.java:>>>>> 3
>>>>>> 3)
>>>>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>>>>> com.skifta.booster.cdir.Activator.start(Activator.java:43)
>>>>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>>>>> org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.j>>>>> a
>>>>>> va
>>>>>> :661)
>>>>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>>>>> org.apache.felix.framework.Felix.activateBundle(Felix.java:1760)
>>>>>> 04-30 12:36:25.798: WARN/System.err(16018):     ... 17 more
>>>>>>
>>>>>>
>>>>>> Any idea why the classloader is not allowing bundles I start to see the
>>>>>> classes in the packages exported by the framework?
>>>>>>
>>>>>> private static final String ANDROID_FRAMEWORK_PACKAGES =
>>>>>> ("org.osgi.framework; version=1.4.0," +
>>>>>>             "org.osgi.service.packageadmin; version=1.2.0," +
>>>>>>             "org.osgi.service.startlevel; version=1.0.0," +
>>>>>>             "org.osgi.service.url; version=1.0.0," +
>>>>>>             "org.osgi.util.tracker," +
>>>>>>             "android; " +
>>>>>>             "android.app;" +
>>>>>>             "android.content;" +
>>>>>>             "android.database;" +
>>>>>>             "android.database.sqlite;" +
>>>>>>             "android.graphics; " +
>>>>>>             "android.graphics.drawable; " +
>>>>>>             "android.graphics.glutils; " +
>>>>>>             "android.hardware; " +
>>>>>>             "android.location; " +
>>>>>>             "android.media; " +
>>>>>>             "android.net; " +
>>>>>>             "android.net.wifi; " +
>>>>>>             "android.opengl; " +
>>>>>>             "android.os; " +
>>>>>>             "android.provider; " +
>>>>>>             "android.sax; " +
>>>>>>             "android.speech.recognition; " +
>>>>>>             "android.telephony; " +
>>>>>>             "android.telephony.gsm; " +
>>>>>>             "android.text; " +
>>>>>>             "android.text.method; " +
>>>>>>             "android.text.style; " +
>>>>>>             "android.text.util; " +
>>>>>>             "android.util; " +
>>>>>>             "android.view; " +
>>>>>>             "android.view.animation; " +
>>>>>>             "android.webkit; " +
>>>>>>             "android.widget; " +
>>>>>>             "com.google.android.maps; " +
>>>>>>             "com.google.android.xmppService; " +
>>>>>>             "javax.crypto; " +
>>>>>>             "javax.crypto.interfaces; " +
>>>>>>             "javax.crypto.spec; " +
>>>>>>             "javax.microedition.khronos.opengles; " +
>>>>>>             "javax.net; " +
>>>>>>             "javax.net.ssl; " +
>>>>>>             "javax.security.auth; " +
>>>>>>             "javax.security.auth.callback; " +
>>>>>>             "javax.security.auth.login; " +
>>>>>>             "javax.security.auth.x500; " +
>>>>>>             "javax.security.cert; " +
>>>>>>             "javax.sound.midi; " +
>>>>>>             "javax.sound.midi.spi; " +
>>>>>>             "javax.sound.sampled; " +
>>>>>>             "javax.sound.sampled.spi; " +
>>>>>>             "javax.sql; " +
>>>>>>             "javax.xml.parsers; " +
>>>>>>             "junit.extensions; " +
>>>>>>             "junit.framework; " +
>>>>>>             "org.apache.commons.codec; " +
>>>>>>             "org.apache.commons.codec.binary; " +
>>>>>>             "org.apache.commons.codec.language; " +
>>>>>>             "org.apache.commons.codec.net; " +
>>>>>>             "org.apache.commons.httpclient; " +
>>>>>>             "org.apache.commons.httpclient.auth; " +
>>>>>>             "org.apache.commons.httpclient.cookie; " +
>>>>>>             "org.apache.commons.httpclient.methods; " +
>>>>>>             "org.apache.commons.httpclient.methods.multipart; " +
>>>>>>             "org.apache.commons.httpclient.params; " +
>>>>>>             "org.apache.commons.httpclient.protocol; " +
>>>>>>             "org.apache.commons.httpclient.util; " +
>>>>>>             "org.json; " +
>>>>>>             "org.w3c.dom; " +
>>>>>>             "org.xml.sax; " +
>>>>>>             "org.xml.sax.ext; " +
>>>>>>             "org.xml.sax.helpers; " +
>>>>>>             "version=1.6.0");
>>>>>>
>>>>>> Properties config = System.getProperties();
>>>>>> config.put("org.osgi.framework.startlevel.beginning",
>>>>>> Integer.toString(SkiftaService.SKIFTA_START_LEVEL));
>>>>>> config.put("org.osgi.framework.storage.clean", "onFirstInit");
>>>>>>
>>>>>> // make sure the OSGi cache dir is set to something sensible
>>>>>>
>>>>>> File cacheDir = this.getDir("osgi.cache", Context.MODE_PRIVATE);
>>>>>> Log.d(TAG, "setting osgi cache location to: " +
>>>>>> cacheDir.getAbsolutePath());
>>>>>> config.put("org.osgi.framework.storage", cacheDir.getAbsolutePath());
>>>>>>
>>>>>>
>>>>>> // calculate the export packages list from the environment
>>>>>>
>>>>>> String sysPackages =
>>>>>> bootProps.getProperty("org.osgi.framework.system.packages.extra");
>>>>>> config.put("org.osgi.framework.system.packages",
>>>>>> ANDROID_FRAMEWORK_PACKAGES);
>>>>>> config.put("felix.log.level", "1");
>>>>>>
>>>>>> // Now create an instance of the framework with
>>>>>> // our configuration properties.
>>>>>>
>>>>>> Log.d(TAG, "Starting Felix...");
>>>>>> felix = new Felix(config);
>>>>>>
>>>>>> // Now start Felix instance.
>>>>>>
>>>>>> felix.start();
>>>>>>
>>>>>>
>>>>>> On 30/04/2010 11:30, "Bruce Jackson"<br...@qualcomm.com>  wrote:
>>>>>>
>>>>>>
>>>>>>> Actually, the problem is one of syntax, apparently. When you pass in the
>>>>>>> Properties object, the value against the key that was read from the file
>>>>>>> attached (i.e. the standard form of these files) it doesn't work.
>>>>>>>
>>>>>>> The list needs to be comma separated with no additional CR LF characters
>>>>>>> or
>>>>>>> the parser doesn't do the right thing.
>>>>>>>
>>>>>>> Clearly there must be some form of pre-parsing going on to handle the
>>>>>>> "standard" package lists in Felix.
>>>>>>>
>>>>>>>
>>>>>>> On 29/04/2010 17:30, "Karl Pauls"<ka...@gmail.com>  wrote:
>>>>>>>
>>>>>>>
>>>>>>>> It should work, can you try to add a
>>>>>>>>
>>>>>>>> ; \
>>>>>>>>   version=\"1.6.0\"
>>>>>>>>
>>>>>>>> to the end of your package list? i.e.,
>>>>>>>>
>>>>>>>>   org.xml.sax.ext; \
>>>>>>>>   org.xml.sax.helpers; \
>>>>>>>>   version=\"1.6.0\"
>>>>>>>>
>>>>>>>>
>>>>>>>> regards,
>>>>>>>>
>>>>>>>> Karl
>>>>>>>>
>>>>>>>> On Wed, Apr 28, 2010 at 7:41 PM, Jackson, Bruce<br...@qualcomm.com>
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>>> Hi All
>>>>>>>>>
>>>>>>>>> I have Felix embedded into an Android app, and I'm trying to export the
>>>>>>>>> packages from the Android environment (e.g. android, android.app, etc)
>>>>>>>>> into
>>>>>>>>> Felix.
>>>>>>>>>
>>>>>>>>> I have a couple of questions: first, can I still use the pre-4.2
>>>>>>>>> constructor:
>>>>>>>>>
>>>>>>>>> Felix felix = new Felix(Properties props);
>>>>>>>>>
>>>>>>>>> ...and if I do so passing in a properties file which contains a
>>>>>>>>> semicolon-seperated list of packages as per the attached, should I see
>>>>>>>>> this
>>>>>>>>> working properly?
>>>>>>>>>
>>>>>>>>> Felix starts ok, but when I try to deploy any bundles to it (for
>>>>>>>>> example
>>>>>>>>> a
>>>>>>>>> dexified org.apache.log4j) I get a message fro the debugger when I
>>>>>>>>> call:
>>>>>>>>>
>>>>>>>>> BundleContent bc = felix.getBundleContent();
>>>>>>>>> bc.installBundle(name, inputStream);
>>>>>>>>>
>>>>>>>>> 04-28 18:31:45.716: ERROR/SkiftaService(6274): Unresolved constraint in
>>>>>>>>> bundle org.apache.log4j [1]: package; (package=javax.xml.parsers)
>>>>>>>>>
>>>>>>>>> ...which seems to suggest that it can't find the package.
>>>>>>>>>
>>>>>>>>> Any ideas?
>>>>>>>>>
>>>>>>>>> Thanks
>>>>>>>>>
>>>>>>>>> Bruce
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>
>



-- 
Karl Pauls
karlpauls@gmail.com

Re: Possible bug in ModuleImpl (was Re: org.osgi.framework.system.packages and Felix embedded in Android)

Posted by "Richard S. Hall" <he...@ungoverned.org>.
On 4/30/10 13:49, Jackson, Bruce wrote:
> I've now followed the Felix code through to the source of this problem which appears to be in ModuleImpl:
>
> static
>      {
>          ClassLoader cl = null;
>          try
>          {
>              Constructor ctor = m_secureAction.getDeclaredConstructor(
>                  SecureClassLoader.class, new Class[] { ClassLoader.class });
>              m_secureAction.setAccesssible(ctor);
>              cl = (ClassLoader) m_secureAction.invoke(ctor, new Object[] { null });
>          }
>          catch (Throwable ex)
>          {
>              // On Android we get an exception if we set the parent class loader
>              // to null, so we will work around that case by setting the parent
>              // class loader to the system class loader in getClassLoader() below.
>              cl = null;
>              System.err.println("Problem creating boot delegation class loader: " + ex);
>              ex.printStackTrace();
>          }
>          m_defBootClassLoader = cl;
>      }
>
> This seems to be trying to create a new instance of SecureClassLoader, which is failing because SecureClassLoader doesn’t have any public constructor. This is therefore throwing an InvocationTargetException and is, I believe responsible for the problem I’m seeing. Has this been reported as a bug, does anyone know?
>    

The call to setAccessible() should make the constructor accessible.

-> richard

> Thanks
>
> Bruce
>
> On 30/04/2010 17:14, "Bruce Jackson"<br...@qualcomm.com>  wrote:
>
>    
>> Yes, I'm aware of that. What I meant was that I've seen that it works on
>> Felix releases with the framework version set to 1.2, but I can't get this
>> working with the current release.
>>
>>
>> On 30/04/2010 17:03, "Richard S. Hall"<he...@ungoverned.org>  wrote:
>>
>>      
>>> On 4/30/10 9:50, Jackson, Bruce wrote:
>>>        
>>>> I've added the lines:
>>>>
>>>> // calculate the export packages list from the environment
>>>>
>>>> config.put("org.osgi.framework.system.packages",
>>>> ANDROID_FRAMEWORK_PACKAGES);
>>>> config.put("org.osgi.framework.bundle.parent", "app");
>>>> config.put("felix.log.level", "1");
>>>>
>>>> and tried this with app, framework, boot and also ext, but I get the same
>>>> result I'm afraid. I've certainly seen out on the web that people have done
>>>> with with almost identical code on earlier version of Felix (I can't be sure
>>>> of the exact Felix version, but the org.osgi.framework version was set to
>>>> 1.2) but is it possible that has become broken in recent releases?
>>>>
>>>>          
>>> That is the version of the OSGi spec, check in the
>>> org.apache.felix.framework.Felix.properties file...
>>>
>>> ->  richard
>>>
>>>        
>>>> Thanks
>>>>
>>>> Bruce
>>>>
>>>> On 30/04/2010 13:34, "Karl Pauls"<ka...@gmail.com>   wrote:
>>>>
>>>>
>>>>          
>>>>>    In case you have problems on android not finding classes that you are
>>>>> making available via the system bundle, make sure you set the
>>>>> org.osgi.framework.bundle.parent property to the correct value (either
>>>>> app or framework, depends). i.e.,
>>>>>
>>>>> org.osgi.framework.bundle.parent=app
>>>>>
>>>>> or
>>>>>
>>>>> org.osgi.framework.bundle.parent=framework
>>>>>
>>>>> that should make it work.
>>>>>
>>>>> regards,
>>>>>
>>>>> Karl
>>>>>
>>>>> On Fri, Apr 30, 2010 at 1:38 PM, Jackson, Bruce<br...@qualcomm.com>
>>>>> wrote:
>>>>>
>>>>>            
>>>>>> As a continuation to this mini-saga, I now have the initial problem (i.e.
>>>>>> bundle resolution) fixed with the code below. When I add bundles to the
>>>>>> running Felix framework, the resolve correctly, and start as long as their
>>>>>> activator does not try to load any of the classes found in
>>>>>> ANDROID_FRAMEWORK_PACKAGES, such as android.util.Log. If they do, I get a
>>>>>> ClassNotFoundException:
>>>>>>
>>>>>> 04-30 12:36:25.788: DEBUG/dalvikvm(16018): Making a copy of
>>>>>> Lcom/skifta/android/mediaserver/AndroidTestImpl;.test4 code (68 bytes)
>>>>>> 04-30 12:36:25.798: WARN/System.err(16018):
>>>>>> org.osgi.framework.BundleException: Activator start error in bundle
>>>>>> com.skifta.booster.cdir [4].
>>>>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>>>>> org.apache.felix.framework.Felix.activateBundle(Felix.java:1807)
>>>>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>>>>> org.apache.felix.framework.Felix.startBundle(Felix.java:1682)
>>>>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>>>>> org.apache.felix.framework.BundleImpl.start(BundleImpl.java:905)
>>>>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>>>>> org.apache.felix.framework.BundleImpl.start(BundleImpl.java:892)
>>>>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>>>>> com.skifta.android.client.SkiftaService.startOSGi(SkiftaService.java:401)
>>>>>> ....
>>>>>> 04-30 12:36:25.798: WARN/System.err(16018): Caused by:
>>>>>> java.lang.NoClassDefFoundError: android.util.Log
>>>>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>>>>> com.skifta.android.mediaserver.AndroidTestImpl.test1(AndroidTestImpl.java:>>>>>  3
>>>>>> 3)
>>>>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>>>>> com.skifta.booster.cdir.Activator.start(Activator.java:43)
>>>>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>>>>> org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.j>>>>>  a
>>>>>> va
>>>>>> :661)
>>>>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>>>>> org.apache.felix.framework.Felix.activateBundle(Felix.java:1760)
>>>>>> 04-30 12:36:25.798: WARN/System.err(16018):     ... 17 more
>>>>>>
>>>>>>
>>>>>> Any idea why the classloader is not allowing bundles I start to see the
>>>>>> classes in the packages exported by the framework?
>>>>>>
>>>>>> private static final String ANDROID_FRAMEWORK_PACKAGES =
>>>>>> ("org.osgi.framework; version=1.4.0," +
>>>>>>              "org.osgi.service.packageadmin; version=1.2.0," +
>>>>>>              "org.osgi.service.startlevel; version=1.0.0," +
>>>>>>              "org.osgi.service.url; version=1.0.0," +
>>>>>>              "org.osgi.util.tracker," +
>>>>>>              "android; " +
>>>>>>              "android.app;" +
>>>>>>              "android.content;" +
>>>>>>              "android.database;" +
>>>>>>              "android.database.sqlite;" +
>>>>>>              "android.graphics; " +
>>>>>>              "android.graphics.drawable; " +
>>>>>>              "android.graphics.glutils; " +
>>>>>>              "android.hardware; " +
>>>>>>              "android.location; " +
>>>>>>              "android.media; " +
>>>>>>              "android.net; " +
>>>>>>              "android.net.wifi; " +
>>>>>>              "android.opengl; " +
>>>>>>              "android.os; " +
>>>>>>              "android.provider; " +
>>>>>>              "android.sax; " +
>>>>>>              "android.speech.recognition; " +
>>>>>>              "android.telephony; " +
>>>>>>              "android.telephony.gsm; " +
>>>>>>              "android.text; " +
>>>>>>              "android.text.method; " +
>>>>>>              "android.text.style; " +
>>>>>>              "android.text.util; " +
>>>>>>              "android.util; " +
>>>>>>              "android.view; " +
>>>>>>              "android.view.animation; " +
>>>>>>              "android.webkit; " +
>>>>>>              "android.widget; " +
>>>>>>              "com.google.android.maps; " +
>>>>>>              "com.google.android.xmppService; " +
>>>>>>              "javax.crypto; " +
>>>>>>              "javax.crypto.interfaces; " +
>>>>>>              "javax.crypto.spec; " +
>>>>>>              "javax.microedition.khronos.opengles; " +
>>>>>>              "javax.net; " +
>>>>>>              "javax.net.ssl; " +
>>>>>>              "javax.security.auth; " +
>>>>>>              "javax.security.auth.callback; " +
>>>>>>              "javax.security.auth.login; " +
>>>>>>              "javax.security.auth.x500; " +
>>>>>>              "javax.security.cert; " +
>>>>>>              "javax.sound.midi; " +
>>>>>>              "javax.sound.midi.spi; " +
>>>>>>              "javax.sound.sampled; " +
>>>>>>              "javax.sound.sampled.spi; " +
>>>>>>              "javax.sql; " +
>>>>>>              "javax.xml.parsers; " +
>>>>>>              "junit.extensions; " +
>>>>>>              "junit.framework; " +
>>>>>>              "org.apache.commons.codec; " +
>>>>>>              "org.apache.commons.codec.binary; " +
>>>>>>              "org.apache.commons.codec.language; " +
>>>>>>              "org.apache.commons.codec.net; " +
>>>>>>              "org.apache.commons.httpclient; " +
>>>>>>              "org.apache.commons.httpclient.auth; " +
>>>>>>              "org.apache.commons.httpclient.cookie; " +
>>>>>>              "org.apache.commons.httpclient.methods; " +
>>>>>>              "org.apache.commons.httpclient.methods.multipart; " +
>>>>>>              "org.apache.commons.httpclient.params; " +
>>>>>>              "org.apache.commons.httpclient.protocol; " +
>>>>>>              "org.apache.commons.httpclient.util; " +
>>>>>>              "org.json; " +
>>>>>>              "org.w3c.dom; " +
>>>>>>              "org.xml.sax; " +
>>>>>>              "org.xml.sax.ext; " +
>>>>>>              "org.xml.sax.helpers; " +
>>>>>>              "version=1.6.0");
>>>>>>
>>>>>> Properties config = System.getProperties();
>>>>>> config.put("org.osgi.framework.startlevel.beginning",
>>>>>> Integer.toString(SkiftaService.SKIFTA_START_LEVEL));
>>>>>> config.put("org.osgi.framework.storage.clean", "onFirstInit");
>>>>>>
>>>>>> // make sure the OSGi cache dir is set to something sensible
>>>>>>
>>>>>> File cacheDir = this.getDir("osgi.cache", Context.MODE_PRIVATE);
>>>>>> Log.d(TAG, "setting osgi cache location to: " +
>>>>>> cacheDir.getAbsolutePath());
>>>>>> config.put("org.osgi.framework.storage", cacheDir.getAbsolutePath());
>>>>>>
>>>>>>
>>>>>> // calculate the export packages list from the environment
>>>>>>
>>>>>> String sysPackages =
>>>>>> bootProps.getProperty("org.osgi.framework.system.packages.extra");
>>>>>> config.put("org.osgi.framework.system.packages",
>>>>>> ANDROID_FRAMEWORK_PACKAGES);
>>>>>> config.put("felix.log.level", "1");
>>>>>>
>>>>>> // Now create an instance of the framework with
>>>>>> // our configuration properties.
>>>>>>
>>>>>> Log.d(TAG, "Starting Felix...");
>>>>>> felix = new Felix(config);
>>>>>>
>>>>>> // Now start Felix instance.
>>>>>>
>>>>>> felix.start();
>>>>>>
>>>>>>
>>>>>> On 30/04/2010 11:30, "Bruce Jackson"<br...@qualcomm.com>   wrote:
>>>>>>
>>>>>>
>>>>>>              
>>>>>>> Actually, the problem is one of syntax, apparently. When you pass in the
>>>>>>> Properties object, the value against the key that was read from the file
>>>>>>> attached (i.e. the standard form of these files) it doesn't work.
>>>>>>>
>>>>>>> The list needs to be comma separated with no additional CR LF characters
>>>>>>> or
>>>>>>> the parser doesn't do the right thing.
>>>>>>>
>>>>>>> Clearly there must be some form of pre-parsing going on to handle the
>>>>>>> "standard" package lists in Felix.
>>>>>>>
>>>>>>>
>>>>>>> On 29/04/2010 17:30, "Karl Pauls"<ka...@gmail.com>   wrote:
>>>>>>>
>>>>>>>
>>>>>>>                
>>>>>>>> It should work, can you try to add a
>>>>>>>>
>>>>>>>> ; \
>>>>>>>>    version=\"1.6.0\"
>>>>>>>>
>>>>>>>> to the end of your package list? i.e.,
>>>>>>>>
>>>>>>>>    org.xml.sax.ext; \
>>>>>>>>    org.xml.sax.helpers; \
>>>>>>>>    version=\"1.6.0\"
>>>>>>>>
>>>>>>>>
>>>>>>>> regards,
>>>>>>>>
>>>>>>>> Karl
>>>>>>>>
>>>>>>>> On Wed, Apr 28, 2010 at 7:41 PM, Jackson, Bruce<br...@qualcomm.com>
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>>                  
>>>>>>>>> Hi All
>>>>>>>>>
>>>>>>>>> I have Felix embedded into an Android app, and I'm trying to export the
>>>>>>>>> packages from the Android environment (e.g. android, android.app, etc)
>>>>>>>>> into
>>>>>>>>> Felix.
>>>>>>>>>
>>>>>>>>> I have a couple of questions: first, can I still use the pre-4.2
>>>>>>>>> constructor:
>>>>>>>>>
>>>>>>>>> Felix felix = new Felix(Properties props);
>>>>>>>>>
>>>>>>>>> ...and if I do so passing in a properties file which contains a
>>>>>>>>> semicolon-seperated list of packages as per the attached, should I see
>>>>>>>>> this
>>>>>>>>> working properly?
>>>>>>>>>
>>>>>>>>> Felix starts ok, but when I try to deploy any bundles to it (for
>>>>>>>>> example
>>>>>>>>> a
>>>>>>>>> dexified org.apache.log4j) I get a message fro the debugger when I
>>>>>>>>> call:
>>>>>>>>>
>>>>>>>>> BundleContent bc = felix.getBundleContent();
>>>>>>>>> bc.installBundle(name, inputStream);
>>>>>>>>>
>>>>>>>>> 04-28 18:31:45.716: ERROR/SkiftaService(6274): Unresolved constraint in
>>>>>>>>> bundle org.apache.log4j [1]: package; (package=javax.xml.parsers)
>>>>>>>>>
>>>>>>>>> ...which seems to suggest that it can't find the package.
>>>>>>>>>
>>>>>>>>> Any ideas?
>>>>>>>>>
>>>>>>>>> Thanks
>>>>>>>>>
>>>>>>>>> Bruce
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                    
>>>>>>>>
>>>>>>>>                  
>>>>>>>                
>>>>>>              
>>>>>
>>>>>            
>>>>          
>>      
>    

Possible bug in ModuleImpl (was Re: org.osgi.framework.system.packages and Felix embedded in Android)

Posted by "Jackson, Bruce" <br...@qualcomm.com>.
I've now followed the Felix code through to the source of this problem which appears to be in ModuleImpl:

static
    {
        ClassLoader cl = null;
        try
        {
            Constructor ctor = m_secureAction.getDeclaredConstructor(
                SecureClassLoader.class, new Class[] { ClassLoader.class });
            m_secureAction.setAccesssible(ctor);
            cl = (ClassLoader) m_secureAction.invoke(ctor, new Object[] { null });
        }
        catch (Throwable ex)
        {
            // On Android we get an exception if we set the parent class loader
            // to null, so we will work around that case by setting the parent
            // class loader to the system class loader in getClassLoader() below.
            cl = null;
            System.err.println("Problem creating boot delegation class loader: " + ex);
            ex.printStackTrace();
        }
        m_defBootClassLoader = cl;
    }

This seems to be trying to create a new instance of SecureClassLoader, which is failing because SecureClassLoader doesn’t have any public constructor. This is therefore throwing an InvocationTargetException and is, I believe responsible for the problem I’m seeing. Has this been reported as a bug, does anyone know?

Thanks

Bruce

On 30/04/2010 17:14, "Bruce Jackson" <br...@qualcomm.com> wrote:

> Yes, I'm aware of that. What I meant was that I've seen that it works on
> Felix releases with the framework version set to 1.2, but I can't get this
> working with the current release.
>
>
> On 30/04/2010 17:03, "Richard S. Hall" <he...@ungoverned.org> wrote:
>
>> On 4/30/10 9:50, Jackson, Bruce wrote:
>>> I've added the lines:
>>>
>>> // calculate the export packages list from the environment
>>>
>>> config.put("org.osgi.framework.system.packages",
>>> ANDROID_FRAMEWORK_PACKAGES);
>>> config.put("org.osgi.framework.bundle.parent", "app");
>>> config.put("felix.log.level", "1");
>>>
>>> and tried this with app, framework, boot and also ext, but I get the same
>>> result I'm afraid. I've certainly seen out on the web that people have done
>>> with with almost identical code on earlier version of Felix (I can't be sure
>>> of the exact Felix version, but the org.osgi.framework version was set to
>>> 1.2) but is it possible that has become broken in recent releases?
>>>
>>
>> That is the version of the OSGi spec, check in the
>> org.apache.felix.framework.Felix.properties file...
>>
>> -> richard
>>
>>> Thanks
>>>
>>> Bruce
>>>
>>> On 30/04/2010 13:34, "Karl Pauls"<ka...@gmail.com>  wrote:
>>>
>>>
>>>>   In case you have problems on android not finding classes that you are
>>>> making available via the system bundle, make sure you set the
>>>> org.osgi.framework.bundle.parent property to the correct value (either
>>>> app or framework, depends). i.e.,
>>>>
>>>> org.osgi.framework.bundle.parent=app
>>>>
>>>> or
>>>>
>>>> org.osgi.framework.bundle.parent=framework
>>>>
>>>> that should make it work.
>>>>
>>>> regards,
>>>>
>>>> Karl
>>>>
>>>> On Fri, Apr 30, 2010 at 1:38 PM, Jackson, Bruce<br...@qualcomm.com>
>>>> wrote:
>>>>
>>>>> As a continuation to this mini-saga, I now have the initial problem (i.e.
>>>>> bundle resolution) fixed with the code below. When I add bundles to the
>>>>> running Felix framework, the resolve correctly, and start as long as their
>>>>> activator does not try to load any of the classes found in
>>>>> ANDROID_FRAMEWORK_PACKAGES, such as android.util.Log. If they do, I get a
>>>>> ClassNotFoundException:
>>>>>
>>>>> 04-30 12:36:25.788: DEBUG/dalvikvm(16018): Making a copy of
>>>>> Lcom/skifta/android/mediaserver/AndroidTestImpl;.test4 code (68 bytes)
>>>>> 04-30 12:36:25.798: WARN/System.err(16018):
>>>>> org.osgi.framework.BundleException: Activator start error in bundle
>>>>> com.skifta.booster.cdir [4].
>>>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>>>> org.apache.felix.framework.Felix.activateBundle(Felix.java:1807)
>>>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>>>> org.apache.felix.framework.Felix.startBundle(Felix.java:1682)
>>>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>>>> org.apache.felix.framework.BundleImpl.start(BundleImpl.java:905)
>>>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>>>> org.apache.felix.framework.BundleImpl.start(BundleImpl.java:892)
>>>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>>>> com.skifta.android.client.SkiftaService.startOSGi(SkiftaService.java:401)
>>>>> ....
>>>>> 04-30 12:36:25.798: WARN/System.err(16018): Caused by:
>>>>> java.lang.NoClassDefFoundError: android.util.Log
>>>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>>>> com.skifta.android.mediaserver.AndroidTestImpl.test1(AndroidTestImpl.java:>>>>> 3
>>>>> 3)
>>>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>>>> com.skifta.booster.cdir.Activator.start(Activator.java:43)
>>>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>>>> org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.j>>>>> a
>>>>> va
>>>>> :661)
>>>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>>>> org.apache.felix.framework.Felix.activateBundle(Felix.java:1760)
>>>>> 04-30 12:36:25.798: WARN/System.err(16018):     ... 17 more
>>>>>
>>>>>
>>>>> Any idea why the classloader is not allowing bundles I start to see the
>>>>> classes in the packages exported by the framework?
>>>>>
>>>>> private static final String ANDROID_FRAMEWORK_PACKAGES =
>>>>> ("org.osgi.framework; version=1.4.0," +
>>>>>             "org.osgi.service.packageadmin; version=1.2.0," +
>>>>>             "org.osgi.service.startlevel; version=1.0.0," +
>>>>>             "org.osgi.service.url; version=1.0.0," +
>>>>>             "org.osgi.util.tracker," +
>>>>>             "android; " +
>>>>>             "android.app;" +
>>>>>             "android.content;" +
>>>>>             "android.database;" +
>>>>>             "android.database.sqlite;" +
>>>>>             "android.graphics; " +
>>>>>             "android.graphics.drawable; " +
>>>>>             "android.graphics.glutils; " +
>>>>>             "android.hardware; " +
>>>>>             "android.location; " +
>>>>>             "android.media; " +
>>>>>             "android.net; " +
>>>>>             "android.net.wifi; " +
>>>>>             "android.opengl; " +
>>>>>             "android.os; " +
>>>>>             "android.provider; " +
>>>>>             "android.sax; " +
>>>>>             "android.speech.recognition; " +
>>>>>             "android.telephony; " +
>>>>>             "android.telephony.gsm; " +
>>>>>             "android.text; " +
>>>>>             "android.text.method; " +
>>>>>             "android.text.style; " +
>>>>>             "android.text.util; " +
>>>>>             "android.util; " +
>>>>>             "android.view; " +
>>>>>             "android.view.animation; " +
>>>>>             "android.webkit; " +
>>>>>             "android.widget; " +
>>>>>             "com.google.android.maps; " +
>>>>>             "com.google.android.xmppService; " +
>>>>>             "javax.crypto; " +
>>>>>             "javax.crypto.interfaces; " +
>>>>>             "javax.crypto.spec; " +
>>>>>             "javax.microedition.khronos.opengles; " +
>>>>>             "javax.net; " +
>>>>>             "javax.net.ssl; " +
>>>>>             "javax.security.auth; " +
>>>>>             "javax.security.auth.callback; " +
>>>>>             "javax.security.auth.login; " +
>>>>>             "javax.security.auth.x500; " +
>>>>>             "javax.security.cert; " +
>>>>>             "javax.sound.midi; " +
>>>>>             "javax.sound.midi.spi; " +
>>>>>             "javax.sound.sampled; " +
>>>>>             "javax.sound.sampled.spi; " +
>>>>>             "javax.sql; " +
>>>>>             "javax.xml.parsers; " +
>>>>>             "junit.extensions; " +
>>>>>             "junit.framework; " +
>>>>>             "org.apache.commons.codec; " +
>>>>>             "org.apache.commons.codec.binary; " +
>>>>>             "org.apache.commons.codec.language; " +
>>>>>             "org.apache.commons.codec.net; " +
>>>>>             "org.apache.commons.httpclient; " +
>>>>>             "org.apache.commons.httpclient.auth; " +
>>>>>             "org.apache.commons.httpclient.cookie; " +
>>>>>             "org.apache.commons.httpclient.methods; " +
>>>>>             "org.apache.commons.httpclient.methods.multipart; " +
>>>>>             "org.apache.commons.httpclient.params; " +
>>>>>             "org.apache.commons.httpclient.protocol; " +
>>>>>             "org.apache.commons.httpclient.util; " +
>>>>>             "org.json; " +
>>>>>             "org.w3c.dom; " +
>>>>>             "org.xml.sax; " +
>>>>>             "org.xml.sax.ext; " +
>>>>>             "org.xml.sax.helpers; " +
>>>>>             "version=1.6.0");
>>>>>
>>>>> Properties config = System.getProperties();
>>>>> config.put("org.osgi.framework.startlevel.beginning",
>>>>> Integer.toString(SkiftaService.SKIFTA_START_LEVEL));
>>>>> config.put("org.osgi.framework.storage.clean", "onFirstInit");
>>>>>
>>>>> // make sure the OSGi cache dir is set to something sensible
>>>>>
>>>>> File cacheDir = this.getDir("osgi.cache", Context.MODE_PRIVATE);
>>>>> Log.d(TAG, "setting osgi cache location to: " +
>>>>> cacheDir.getAbsolutePath());
>>>>> config.put("org.osgi.framework.storage", cacheDir.getAbsolutePath());
>>>>>
>>>>>
>>>>> // calculate the export packages list from the environment
>>>>>
>>>>> String sysPackages =
>>>>> bootProps.getProperty("org.osgi.framework.system.packages.extra");
>>>>> config.put("org.osgi.framework.system.packages",
>>>>> ANDROID_FRAMEWORK_PACKAGES);
>>>>> config.put("felix.log.level", "1");
>>>>>
>>>>> // Now create an instance of the framework with
>>>>> // our configuration properties.
>>>>>
>>>>> Log.d(TAG, "Starting Felix...");
>>>>> felix = new Felix(config);
>>>>>
>>>>> // Now start Felix instance.
>>>>>
>>>>> felix.start();
>>>>>
>>>>>
>>>>> On 30/04/2010 11:30, "Bruce Jackson"<br...@qualcomm.com>  wrote:
>>>>>
>>>>>
>>>>>> Actually, the problem is one of syntax, apparently. When you pass in the
>>>>>> Properties object, the value against the key that was read from the file
>>>>>> attached (i.e. the standard form of these files) it doesn't work.
>>>>>>
>>>>>> The list needs to be comma separated with no additional CR LF characters
>>>>>> or
>>>>>> the parser doesn't do the right thing.
>>>>>>
>>>>>> Clearly there must be some form of pre-parsing going on to handle the
>>>>>> "standard" package lists in Felix.
>>>>>>
>>>>>>
>>>>>> On 29/04/2010 17:30, "Karl Pauls"<ka...@gmail.com>  wrote:
>>>>>>
>>>>>>
>>>>>>> It should work, can you try to add a
>>>>>>>
>>>>>>> ; \
>>>>>>>   version=\"1.6.0\"
>>>>>>>
>>>>>>> to the end of your package list? i.e.,
>>>>>>>
>>>>>>>   org.xml.sax.ext; \
>>>>>>>   org.xml.sax.helpers; \
>>>>>>>   version=\"1.6.0\"
>>>>>>>
>>>>>>>
>>>>>>> regards,
>>>>>>>
>>>>>>> Karl
>>>>>>>
>>>>>>> On Wed, Apr 28, 2010 at 7:41 PM, Jackson, Bruce<br...@qualcomm.com>
>>>>>>> wrote:
>>>>>>>
>>>>>>>> Hi All
>>>>>>>>
>>>>>>>> I have Felix embedded into an Android app, and I'm trying to export the
>>>>>>>> packages from the Android environment (e.g. android, android.app, etc)
>>>>>>>> into
>>>>>>>> Felix.
>>>>>>>>
>>>>>>>> I have a couple of questions: first, can I still use the pre-4.2
>>>>>>>> constructor:
>>>>>>>>
>>>>>>>> Felix felix = new Felix(Properties props);
>>>>>>>>
>>>>>>>> ...and if I do so passing in a properties file which contains a
>>>>>>>> semicolon-seperated list of packages as per the attached, should I see
>>>>>>>> this
>>>>>>>> working properly?
>>>>>>>>
>>>>>>>> Felix starts ok, but when I try to deploy any bundles to it (for
>>>>>>>> example
>>>>>>>> a
>>>>>>>> dexified org.apache.log4j) I get a message fro the debugger when I
>>>>>>>> call:
>>>>>>>>
>>>>>>>> BundleContent bc = felix.getBundleContent();
>>>>>>>> bc.installBundle(name, inputStream);
>>>>>>>>
>>>>>>>> 04-28 18:31:45.716: ERROR/SkiftaService(6274): Unresolved constraint in
>>>>>>>> bundle org.apache.log4j [1]: package; (package=javax.xml.parsers)
>>>>>>>>
>>>>>>>> ...which seems to suggest that it can't find the package.
>>>>>>>>
>>>>>>>> Any ideas?
>>>>>>>>
>>>>>>>> Thanks
>>>>>>>>
>>>>>>>> Bruce
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>
>>>>
>>>
>

Re: org.osgi.framework.system.packages and Felix embedded in Android

Posted by "Jackson, Bruce" <br...@qualcomm.com>.
Yes, I'm aware of that. What I meant was that I've seen that it works on
Felix releases with the framework version set to 1.2, but I can't get this
working with the current release.


On 30/04/2010 17:03, "Richard S. Hall" <he...@ungoverned.org> wrote:

> On 4/30/10 9:50, Jackson, Bruce wrote:
>> I've added the lines:
>> 
>> // calculate the export packages list from the environment
>> 
>> config.put("org.osgi.framework.system.packages",
>> ANDROID_FRAMEWORK_PACKAGES);
>> config.put("org.osgi.framework.bundle.parent", "app");
>> config.put("felix.log.level", "1");
>> 
>> and tried this with app, framework, boot and also ext, but I get the same
>> result I'm afraid. I've certainly seen out on the web that people have done
>> with with almost identical code on earlier version of Felix (I can't be sure
>> of the exact Felix version, but the org.osgi.framework version was set to
>> 1.2) but is it possible that has become broken in recent releases?
>> 
> 
> That is the version of the OSGi spec, check in the
> org.apache.felix.framework.Felix.properties file...
> 
> -> richard
> 
>> Thanks
>> 
>> Bruce
>> 
>> On 30/04/2010 13:34, "Karl Pauls"<ka...@gmail.com>  wrote:
>> 
>> 
>>>   In case you have problems on android not finding classes that you are
>>> making available via the system bundle, make sure you set the
>>> org.osgi.framework.bundle.parent property to the correct value (either
>>> app or framework, depends). i.e.,
>>> 
>>> org.osgi.framework.bundle.parent=app
>>> 
>>> or
>>> 
>>> org.osgi.framework.bundle.parent=framework
>>> 
>>> that should make it work.
>>> 
>>> regards,
>>> 
>>> Karl
>>> 
>>> On Fri, Apr 30, 2010 at 1:38 PM, Jackson, Bruce<br...@qualcomm.com>  wrote:
>>> 
>>>> As a continuation to this mini-saga, I now have the initial problem (i.e.
>>>> bundle resolution) fixed with the code below. When I add bundles to the
>>>> running Felix framework, the resolve correctly, and start as long as their
>>>> activator does not try to load any of the classes found in
>>>> ANDROID_FRAMEWORK_PACKAGES, such as android.util.Log. If they do, I get a
>>>> ClassNotFoundException:
>>>> 
>>>> 04-30 12:36:25.788: DEBUG/dalvikvm(16018): Making a copy of
>>>> Lcom/skifta/android/mediaserver/AndroidTestImpl;.test4 code (68 bytes)
>>>> 04-30 12:36:25.798: WARN/System.err(16018):
>>>> org.osgi.framework.BundleException: Activator start error in bundle
>>>> com.skifta.booster.cdir [4].
>>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>>> org.apache.felix.framework.Felix.activateBundle(Felix.java:1807)
>>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>>> org.apache.felix.framework.Felix.startBundle(Felix.java:1682)
>>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>>> org.apache.felix.framework.BundleImpl.start(BundleImpl.java:905)
>>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>>> org.apache.felix.framework.BundleImpl.start(BundleImpl.java:892)
>>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>>> com.skifta.android.client.SkiftaService.startOSGi(SkiftaService.java:401)
>>>> ....
>>>> 04-30 12:36:25.798: WARN/System.err(16018): Caused by:
>>>> java.lang.NoClassDefFoundError: android.util.Log
>>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>>> com.skifta.android.mediaserver.AndroidTestImpl.test1(AndroidTestImpl.java:3
>>>> 3)
>>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>>> com.skifta.booster.cdir.Activator.start(Activator.java:43)
>>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>>> org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.ja
>>>> va
>>>> :661)
>>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>>> org.apache.felix.framework.Felix.activateBundle(Felix.java:1760)
>>>> 04-30 12:36:25.798: WARN/System.err(16018):     ... 17 more
>>>> 
>>>> 
>>>> Any idea why the classloader is not allowing bundles I start to see the
>>>> classes in the packages exported by the framework?
>>>> 
>>>> private static final String ANDROID_FRAMEWORK_PACKAGES =
>>>> ("org.osgi.framework; version=1.4.0," +
>>>>             "org.osgi.service.packageadmin; version=1.2.0," +
>>>>             "org.osgi.service.startlevel; version=1.0.0," +
>>>>             "org.osgi.service.url; version=1.0.0," +
>>>>             "org.osgi.util.tracker," +
>>>>             "android; " +
>>>>             "android.app;" +
>>>>             "android.content;" +
>>>>             "android.database;" +
>>>>             "android.database.sqlite;" +
>>>>             "android.graphics; " +
>>>>             "android.graphics.drawable; " +
>>>>             "android.graphics.glutils; " +
>>>>             "android.hardware; " +
>>>>             "android.location; " +
>>>>             "android.media; " +
>>>>             "android.net; " +
>>>>             "android.net.wifi; " +
>>>>             "android.opengl; " +
>>>>             "android.os; " +
>>>>             "android.provider; " +
>>>>             "android.sax; " +
>>>>             "android.speech.recognition; " +
>>>>             "android.telephony; " +
>>>>             "android.telephony.gsm; " +
>>>>             "android.text; " +
>>>>             "android.text.method; " +
>>>>             "android.text.style; " +
>>>>             "android.text.util; " +
>>>>             "android.util; " +
>>>>             "android.view; " +
>>>>             "android.view.animation; " +
>>>>             "android.webkit; " +
>>>>             "android.widget; " +
>>>>             "com.google.android.maps; " +
>>>>             "com.google.android.xmppService; " +
>>>>             "javax.crypto; " +
>>>>             "javax.crypto.interfaces; " +
>>>>             "javax.crypto.spec; " +
>>>>             "javax.microedition.khronos.opengles; " +
>>>>             "javax.net; " +
>>>>             "javax.net.ssl; " +
>>>>             "javax.security.auth; " +
>>>>             "javax.security.auth.callback; " +
>>>>             "javax.security.auth.login; " +
>>>>             "javax.security.auth.x500; " +
>>>>             "javax.security.cert; " +
>>>>             "javax.sound.midi; " +
>>>>             "javax.sound.midi.spi; " +
>>>>             "javax.sound.sampled; " +
>>>>             "javax.sound.sampled.spi; " +
>>>>             "javax.sql; " +
>>>>             "javax.xml.parsers; " +
>>>>             "junit.extensions; " +
>>>>             "junit.framework; " +
>>>>             "org.apache.commons.codec; " +
>>>>             "org.apache.commons.codec.binary; " +
>>>>             "org.apache.commons.codec.language; " +
>>>>             "org.apache.commons.codec.net; " +
>>>>             "org.apache.commons.httpclient; " +
>>>>             "org.apache.commons.httpclient.auth; " +
>>>>             "org.apache.commons.httpclient.cookie; " +
>>>>             "org.apache.commons.httpclient.methods; " +
>>>>             "org.apache.commons.httpclient.methods.multipart; " +
>>>>             "org.apache.commons.httpclient.params; " +
>>>>             "org.apache.commons.httpclient.protocol; " +
>>>>             "org.apache.commons.httpclient.util; " +
>>>>             "org.json; " +
>>>>             "org.w3c.dom; " +
>>>>             "org.xml.sax; " +
>>>>             "org.xml.sax.ext; " +
>>>>             "org.xml.sax.helpers; " +
>>>>             "version=1.6.0");
>>>> 
>>>> Properties config = System.getProperties();
>>>> config.put("org.osgi.framework.startlevel.beginning",
>>>> Integer.toString(SkiftaService.SKIFTA_START_LEVEL));
>>>> config.put("org.osgi.framework.storage.clean", "onFirstInit");
>>>> 
>>>> // make sure the OSGi cache dir is set to something sensible
>>>> 
>>>> File cacheDir = this.getDir("osgi.cache", Context.MODE_PRIVATE);
>>>> Log.d(TAG, "setting osgi cache location to: " +
>>>> cacheDir.getAbsolutePath());
>>>> config.put("org.osgi.framework.storage", cacheDir.getAbsolutePath());
>>>> 
>>>> 
>>>> // calculate the export packages list from the environment
>>>> 
>>>> String sysPackages =
>>>> bootProps.getProperty("org.osgi.framework.system.packages.extra");
>>>> config.put("org.osgi.framework.system.packages",
>>>> ANDROID_FRAMEWORK_PACKAGES);
>>>> config.put("felix.log.level", "1");
>>>> 
>>>> // Now create an instance of the framework with
>>>> // our configuration properties.
>>>> 
>>>> Log.d(TAG, "Starting Felix...");
>>>> felix = new Felix(config);
>>>> 
>>>> // Now start Felix instance.
>>>> 
>>>> felix.start();
>>>> 
>>>> 
>>>> On 30/04/2010 11:30, "Bruce Jackson"<br...@qualcomm.com>  wrote:
>>>> 
>>>> 
>>>>> Actually, the problem is one of syntax, apparently. When you pass in the
>>>>> Properties object, the value against the key that was read from the file
>>>>> attached (i.e. the standard form of these files) it doesn't work.
>>>>> 
>>>>> The list needs to be comma separated with no additional CR LF characters
>>>>> or
>>>>> the parser doesn't do the right thing.
>>>>> 
>>>>> Clearly there must be some form of pre-parsing going on to handle the
>>>>> "standard" package lists in Felix.
>>>>> 
>>>>> 
>>>>> On 29/04/2010 17:30, "Karl Pauls"<ka...@gmail.com>  wrote:
>>>>> 
>>>>> 
>>>>>> It should work, can you try to add a
>>>>>> 
>>>>>> ; \
>>>>>>   version=\"1.6.0\"
>>>>>> 
>>>>>> to the end of your package list? i.e.,
>>>>>> 
>>>>>>   org.xml.sax.ext; \
>>>>>>   org.xml.sax.helpers; \
>>>>>>   version=\"1.6.0\"
>>>>>> 
>>>>>> 
>>>>>> regards,
>>>>>> 
>>>>>> Karl
>>>>>> 
>>>>>> On Wed, Apr 28, 2010 at 7:41 PM, Jackson, Bruce<br...@qualcomm.com>
>>>>>> wrote:
>>>>>> 
>>>>>>> Hi All
>>>>>>> 
>>>>>>> I have Felix embedded into an Android app, and I'm trying to export the
>>>>>>> packages from the Android environment (e.g. android, android.app, etc)
>>>>>>> into
>>>>>>> Felix.
>>>>>>> 
>>>>>>> I have a couple of questions: first, can I still use the pre-4.2
>>>>>>> constructor:
>>>>>>> 
>>>>>>> Felix felix = new Felix(Properties props);
>>>>>>> 
>>>>>>> ...and if I do so passing in a properties file which contains a
>>>>>>> semicolon-seperated list of packages as per the attached, should I see
>>>>>>> this
>>>>>>> working properly?
>>>>>>> 
>>>>>>> Felix starts ok, but when I try to deploy any bundles to it (for example
>>>>>>> a
>>>>>>> dexified org.apache.log4j) I get a message fro the debugger when I call:
>>>>>>> 
>>>>>>> BundleContent bc = felix.getBundleContent();
>>>>>>> bc.installBundle(name, inputStream);
>>>>>>> 
>>>>>>> 04-28 18:31:45.716: ERROR/SkiftaService(6274): Unresolved constraint in
>>>>>>> bundle org.apache.log4j [1]: package; (package=javax.xml.parsers)
>>>>>>> 
>>>>>>> ...which seems to suggest that it can't find the package.
>>>>>>> 
>>>>>>> Any ideas?
>>>>>>> 
>>>>>>> Thanks
>>>>>>> 
>>>>>>> Bruce
>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>> 
>>>>>> 
>>>>> 
>>>> 
>>> 
>>> 
>> 


Re: org.osgi.framework.system.packages and Felix embedded in Android

Posted by "Richard S. Hall" <he...@ungoverned.org>.
On 4/30/10 9:50, Jackson, Bruce wrote:
> I've added the lines:
>
> // calculate the export packages list from the environment
>
> config.put("org.osgi.framework.system.packages",
> ANDROID_FRAMEWORK_PACKAGES);
> config.put("org.osgi.framework.bundle.parent", "app");
> config.put("felix.log.level", "1");
>
> and tried this with app, framework, boot and also ext, but I get the same
> result I'm afraid. I've certainly seen out on the web that people have done
> with with almost identical code on earlier version of Felix (I can't be sure
> of the exact Felix version, but the org.osgi.framework version was set to
> 1.2) but is it possible that has become broken in recent releases?
>    

That is the version of the OSGi spec, check in the 
org.apache.felix.framework.Felix.properties file...

-> richard

> Thanks
>
> Bruce
>
> On 30/04/2010 13:34, "Karl Pauls"<ka...@gmail.com>  wrote:
>
>    
>>   In case you have problems on android not finding classes that you are
>> making available via the system bundle, make sure you set the
>> org.osgi.framework.bundle.parent property to the correct value (either
>> app or framework, depends). i.e.,
>>
>> org.osgi.framework.bundle.parent=app
>>
>> or
>>
>> org.osgi.framework.bundle.parent=framework
>>
>> that should make it work.
>>
>> regards,
>>
>> Karl
>>
>> On Fri, Apr 30, 2010 at 1:38 PM, Jackson, Bruce<br...@qualcomm.com>  wrote:
>>      
>>> As a continuation to this mini-saga, I now have the initial problem (i.e.
>>> bundle resolution) fixed with the code below. When I add bundles to the
>>> running Felix framework, the resolve correctly, and start as long as their
>>> activator does not try to load any of the classes found in
>>> ANDROID_FRAMEWORK_PACKAGES, such as android.util.Log. If they do, I get a
>>> ClassNotFoundException:
>>>
>>> 04-30 12:36:25.788: DEBUG/dalvikvm(16018): Making a copy of
>>> Lcom/skifta/android/mediaserver/AndroidTestImpl;.test4 code (68 bytes)
>>> 04-30 12:36:25.798: WARN/System.err(16018):
>>> org.osgi.framework.BundleException: Activator start error in bundle
>>> com.skifta.booster.cdir [4].
>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>> org.apache.felix.framework.Felix.activateBundle(Felix.java:1807)
>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>> org.apache.felix.framework.Felix.startBundle(Felix.java:1682)
>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>> org.apache.felix.framework.BundleImpl.start(BundleImpl.java:905)
>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>> org.apache.felix.framework.BundleImpl.start(BundleImpl.java:892)
>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>> com.skifta.android.client.SkiftaService.startOSGi(SkiftaService.java:401)
>>> ....
>>> 04-30 12:36:25.798: WARN/System.err(16018): Caused by:
>>> java.lang.NoClassDefFoundError: android.util.Log
>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>> com.skifta.android.mediaserver.AndroidTestImpl.test1(AndroidTestImpl.java:33)
>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>> com.skifta.booster.cdir.Activator.start(Activator.java:43)
>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>> org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java
>>> :661)
>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>> org.apache.felix.framework.Felix.activateBundle(Felix.java:1760)
>>> 04-30 12:36:25.798: WARN/System.err(16018):     ... 17 more
>>>
>>>
>>> Any idea why the classloader is not allowing bundles I start to see the
>>> classes in the packages exported by the framework?
>>>
>>> private static final String ANDROID_FRAMEWORK_PACKAGES =
>>> ("org.osgi.framework; version=1.4.0," +
>>>             "org.osgi.service.packageadmin; version=1.2.0," +
>>>             "org.osgi.service.startlevel; version=1.0.0," +
>>>             "org.osgi.service.url; version=1.0.0," +
>>>             "org.osgi.util.tracker," +
>>>             "android; " +
>>>             "android.app;" +
>>>             "android.content;" +
>>>             "android.database;" +
>>>             "android.database.sqlite;" +
>>>             "android.graphics; " +
>>>             "android.graphics.drawable; " +
>>>             "android.graphics.glutils; " +
>>>             "android.hardware; " +
>>>             "android.location; " +
>>>             "android.media; " +
>>>             "android.net; " +
>>>             "android.net.wifi; " +
>>>             "android.opengl; " +
>>>             "android.os; " +
>>>             "android.provider; " +
>>>             "android.sax; " +
>>>             "android.speech.recognition; " +
>>>             "android.telephony; " +
>>>             "android.telephony.gsm; " +
>>>             "android.text; " +
>>>             "android.text.method; " +
>>>             "android.text.style; " +
>>>             "android.text.util; " +
>>>             "android.util; " +
>>>             "android.view; " +
>>>             "android.view.animation; " +
>>>             "android.webkit; " +
>>>             "android.widget; " +
>>>             "com.google.android.maps; " +
>>>             "com.google.android.xmppService; " +
>>>             "javax.crypto; " +
>>>             "javax.crypto.interfaces; " +
>>>             "javax.crypto.spec; " +
>>>             "javax.microedition.khronos.opengles; " +
>>>             "javax.net; " +
>>>             "javax.net.ssl; " +
>>>             "javax.security.auth; " +
>>>             "javax.security.auth.callback; " +
>>>             "javax.security.auth.login; " +
>>>             "javax.security.auth.x500; " +
>>>             "javax.security.cert; " +
>>>             "javax.sound.midi; " +
>>>             "javax.sound.midi.spi; " +
>>>             "javax.sound.sampled; " +
>>>             "javax.sound.sampled.spi; " +
>>>             "javax.sql; " +
>>>             "javax.xml.parsers; " +
>>>             "junit.extensions; " +
>>>             "junit.framework; " +
>>>             "org.apache.commons.codec; " +
>>>             "org.apache.commons.codec.binary; " +
>>>             "org.apache.commons.codec.language; " +
>>>             "org.apache.commons.codec.net; " +
>>>             "org.apache.commons.httpclient; " +
>>>             "org.apache.commons.httpclient.auth; " +
>>>             "org.apache.commons.httpclient.cookie; " +
>>>             "org.apache.commons.httpclient.methods; " +
>>>             "org.apache.commons.httpclient.methods.multipart; " +
>>>             "org.apache.commons.httpclient.params; " +
>>>             "org.apache.commons.httpclient.protocol; " +
>>>             "org.apache.commons.httpclient.util; " +
>>>             "org.json; " +
>>>             "org.w3c.dom; " +
>>>             "org.xml.sax; " +
>>>             "org.xml.sax.ext; " +
>>>             "org.xml.sax.helpers; " +
>>>             "version=1.6.0");
>>>
>>> Properties config = System.getProperties();
>>> config.put("org.osgi.framework.startlevel.beginning",
>>> Integer.toString(SkiftaService.SKIFTA_START_LEVEL));
>>> config.put("org.osgi.framework.storage.clean", "onFirstInit");
>>>
>>> // make sure the OSGi cache dir is set to something sensible
>>>
>>> File cacheDir = this.getDir("osgi.cache", Context.MODE_PRIVATE);
>>> Log.d(TAG, "setting osgi cache location to: " + cacheDir.getAbsolutePath());
>>> config.put("org.osgi.framework.storage", cacheDir.getAbsolutePath());
>>>
>>>
>>> // calculate the export packages list from the environment
>>>
>>> String sysPackages =
>>> bootProps.getProperty("org.osgi.framework.system.packages.extra");
>>> config.put("org.osgi.framework.system.packages", ANDROID_FRAMEWORK_PACKAGES);
>>> config.put("felix.log.level", "1");
>>>
>>> // Now create an instance of the framework with
>>> // our configuration properties.
>>>
>>> Log.d(TAG, "Starting Felix...");
>>> felix = new Felix(config);
>>>
>>> // Now start Felix instance.
>>>
>>> felix.start();
>>>
>>>
>>> On 30/04/2010 11:30, "Bruce Jackson"<br...@qualcomm.com>  wrote:
>>>
>>>        
>>>> Actually, the problem is one of syntax, apparently. When you pass in the
>>>> Properties object, the value against the key that was read from the file
>>>> attached (i.e. the standard form of these files) it doesn't work.
>>>>
>>>> The list needs to be comma separated with no additional CR LF characters or
>>>> the parser doesn't do the right thing.
>>>>
>>>> Clearly there must be some form of pre-parsing going on to handle the
>>>> "standard" package lists in Felix.
>>>>
>>>>
>>>> On 29/04/2010 17:30, "Karl Pauls"<ka...@gmail.com>  wrote:
>>>>
>>>>          
>>>>> It should work, can you try to add a
>>>>>
>>>>> ; \
>>>>>   version=\"1.6.0\"
>>>>>
>>>>> to the end of your package list? i.e.,
>>>>>
>>>>>   org.xml.sax.ext; \
>>>>>   org.xml.sax.helpers; \
>>>>>   version=\"1.6.0\"
>>>>>
>>>>>
>>>>> regards,
>>>>>
>>>>> Karl
>>>>>
>>>>> On Wed, Apr 28, 2010 at 7:41 PM, Jackson, Bruce<br...@qualcomm.com>
>>>>> wrote:
>>>>>            
>>>>>> Hi All
>>>>>>
>>>>>> I have Felix embedded into an Android app, and I'm trying to export the
>>>>>> packages from the Android environment (e.g. android, android.app, etc)
>>>>>> into
>>>>>> Felix.
>>>>>>
>>>>>> I have a couple of questions: first, can I still use the pre-4.2
>>>>>> constructor:
>>>>>>
>>>>>> Felix felix = new Felix(Properties props);
>>>>>>
>>>>>> ...and if I do so passing in a properties file which contains a
>>>>>> semicolon-seperated list of packages as per the attached, should I see
>>>>>> this
>>>>>> working properly?
>>>>>>
>>>>>> Felix starts ok, but when I try to deploy any bundles to it (for example a
>>>>>> dexified org.apache.log4j) I get a message fro the debugger when I call:
>>>>>>
>>>>>> BundleContent bc = felix.getBundleContent();
>>>>>> bc.installBundle(name, inputStream);
>>>>>>
>>>>>> 04-28 18:31:45.716: ERROR/SkiftaService(6274): Unresolved constraint in
>>>>>> bundle org.apache.log4j [1]: package; (package=javax.xml.parsers)
>>>>>>
>>>>>> ...which seems to suggest that it can't find the package.
>>>>>>
>>>>>> Any ideas?
>>>>>>
>>>>>> Thanks
>>>>>>
>>>>>> Bruce
>>>>>>
>>>>>>
>>>>>>              
>>>>>
>>>>>            
>>>>          
>>>        
>>
>>      
>    

Re: org.osgi.framework.system.packages and Felix embedded in Android

Posted by Karl Pauls <ka...@gmail.com>.
This should not be a problem. It is just a warning that you can ignore.

regards,

Karl

On Fri, Apr 30, 2010 at 4:06 PM, Jackson, Bruce <br...@qualcomm.com> wrote:
> Further investigationf of the Android logs revels the following message
> which appears just after calling Felix.start():
>
> 04-30 15:01:16.977: WARN/System.err(18939): Problem creating boot delegation
> class loader: java.lang.reflect.InvocationTargetException
> 04-30 15:01:17.117: WARN/System.err(18939): ClassLoader =
> dalvik.system.PathClassLoader - dalvik.system.PathClassLoader@46502120
> 04-30 15:01:17.187: WARN/System.err(245): java.io.IOException: Error running
> exec(). Commands: [/system/xbin/su, 0, /system/bin/rm,
> /data/local/tmp/com.skifta.android.apk] Working Directory: null Environment:
> null
> 04-30 15:01:17.187: WARN/System.err(245):     at
> java.lang.ProcessManager.exec(ProcessManager.java:196)
> 04-30 15:01:17.187: WARN/System.err(245):     at
> java.lang.Runtime.exec(Runtime.java:225)
> 04-30 15:01:17.187: WARN/System.err(245):     at
> java.lang.Runtime.exec(Runtime.java:313)
> 04-30 15:01:17.187: WARN/System.err(245):     at
> java.lang.Runtime.exec(Runtime.java:246)
> 04-30 15:01:17.187: WARN/System.err(245):     at
> com.htc.android.psclient.PackageInstallationReceiver.removeTempPackageFile(P
> ackageInstallationReceiver.java:34)
> 04-30 15:01:17.187: WARN/System.err(245):     at
> com.htc.android.psclient.PackageInstallationReceiver.access$000(PackageInsta
> llationReceiver.java:8)
> 04-30 15:01:17.187: WARN/System.err(245):     at
> com.htc.android.psclient.PackageInstallationReceiver$1.run(PackageInstallati
> onReceiver.java:24)
> 04-30 15:01:17.187: WARN/System.err(245): Caused by: java.io.IOException: No
> such file or directory
> 04-30 15:01:17.197: WARN/System.err(245):     at
> java.lang.ProcessManager.exec(Native Method)
> 04-30 15:01:17.197: WARN/System.err(245):     at
> java.lang.ProcessManager.exec(ProcessManager.java:194)
> 04-30 15:01:17.197: WARN/System.err(245):     ... 6 more
>
>
>
> On 30/04/2010 14:50, "Bruce Jackson" <br...@qualcomm.com> wrote:
>
>> I've added the lines:
>>
>> // calculate the export packages list from the environment
>>
>> config.put("org.osgi.framework.system.packages",
>> ANDROID_FRAMEWORK_PACKAGES);
>> config.put("org.osgi.framework.bundle.parent", "app");
>> config.put("felix.log.level", "1");
>>
>> and tried this with app, framework, boot and also ext, but I get the same
>> result I'm afraid. I've certainly seen out on the web that people have done
>> with with almost identical code on earlier version of Felix (I can't be sure
>> of the exact Felix version, but the org.osgi.framework version was set to
>> 1.2) but is it possible that has become broken in recent releases?
>>
>> Thanks
>>
>> Bruce
>>
>> On 30/04/2010 13:34, "Karl Pauls" <ka...@gmail.com> wrote:
>>
>>>  In case you have problems on android not finding classes that you are
>>> making available via the system bundle, make sure you set the
>>> org.osgi.framework.bundle.parent property to the correct value (either
>>> app or framework, depends). i.e.,
>>>
>>> org.osgi.framework.bundle.parent=app
>>>
>>> or
>>>
>>> org.osgi.framework.bundle.parent=framework
>>>
>>> that should make it work.
>>>
>>> regards,
>>>
>>> Karl
>>>
>>> On Fri, Apr 30, 2010 at 1:38 PM, Jackson, Bruce <br...@qualcomm.com> wrote:
>>>> As a continuation to this mini-saga, I now have the initial problem (i.e.
>>>> bundle resolution) fixed with the code below. When I add bundles to the
>>>> running Felix framework, the resolve correctly, and start as long as their
>>>> activator does not try to load any of the classes found in
>>>> ANDROID_FRAMEWORK_PACKAGES, such as android.util.Log. If they do, I get a
>>>> ClassNotFoundException:
>>>>
>>>> 04-30 12:36:25.788: DEBUG/dalvikvm(16018): Making a copy of
>>>> Lcom/skifta/android/mediaserver/AndroidTestImpl;.test4 code (68 bytes)
>>>> 04-30 12:36:25.798: WARN/System.err(16018):
>>>> org.osgi.framework.BundleException: Activator start error in bundle
>>>> com.skifta.booster.cdir [4].
>>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>>> org.apache.felix.framework.Felix.activateBundle(Felix.java:1807)
>>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>>> org.apache.felix.framework.Felix.startBundle(Felix.java:1682)
>>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>>> org.apache.felix.framework.BundleImpl.start(BundleImpl.java:905)
>>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>>> org.apache.felix.framework.BundleImpl.start(BundleImpl.java:892)
>>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>>> com.skifta.android.client.SkiftaService.startOSGi(SkiftaService.java:401)
>>>> ....
>>>> 04-30 12:36:25.798: WARN/System.err(16018): Caused by:
>>>> java.lang.NoClassDefFoundError: android.util.Log
>>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>>>
> com.skifta.android.mediaserver.AndroidTestImpl.test1(AndroidTestImpl.java:33>>>
> )
>>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>>> com.skifta.booster.cdir.Activator.start(Activator.java:43)
>>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>>>
> org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.jav>>>
> a
>>>> :661)
>>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>>> org.apache.felix.framework.Felix.activateBundle(Felix.java:1760)
>>>> 04-30 12:36:25.798: WARN/System.err(16018):     ... 17 more
>>>>
>>>>
>>>> Any idea why the classloader is not allowing bundles I start to see the
>>>> classes in the packages exported by the framework?
>>>>
>>>> private static final String ANDROID_FRAMEWORK_PACKAGES =
>>>> ("org.osgi.framework; version=1.4.0," +
>>>>            "org.osgi.service.packageadmin; version=1.2.0," +
>>>>            "org.osgi.service.startlevel; version=1.0.0," +
>>>>            "org.osgi.service.url; version=1.0.0," +
>>>>            "org.osgi.util.tracker," +
>>>>            "android; " +
>>>>            "android.app;" +
>>>>            "android.content;" +
>>>>            "android.database;" +
>>>>            "android.database.sqlite;" +
>>>>            "android.graphics; " +
>>>>            "android.graphics.drawable; " +
>>>>            "android.graphics.glutils; " +
>>>>            "android.hardware; " +
>>>>            "android.location; " +
>>>>            "android.media; " +
>>>>            "android.net; " +
>>>>            "android.net.wifi; " +
>>>>            "android.opengl; " +
>>>>            "android.os; " +
>>>>            "android.provider; " +
>>>>            "android.sax; " +
>>>>            "android.speech.recognition; " +
>>>>            "android.telephony; " +
>>>>            "android.telephony.gsm; " +
>>>>            "android.text; " +
>>>>            "android.text.method; " +
>>>>            "android.text.style; " +
>>>>            "android.text.util; " +
>>>>            "android.util; " +
>>>>            "android.view; " +
>>>>            "android.view.animation; " +
>>>>            "android.webkit; " +
>>>>            "android.widget; " +
>>>>            "com.google.android.maps; " +
>>>>            "com.google.android.xmppService; " +
>>>>            "javax.crypto; " +
>>>>            "javax.crypto.interfaces; " +
>>>>            "javax.crypto.spec; " +
>>>>            "javax.microedition.khronos.opengles; " +
>>>>            "javax.net; " +
>>>>            "javax.net.ssl; " +
>>>>            "javax.security.auth; " +
>>>>            "javax.security.auth.callback; " +
>>>>            "javax.security.auth.login; " +
>>>>            "javax.security.auth.x500; " +
>>>>            "javax.security.cert; " +
>>>>            "javax.sound.midi; " +
>>>>            "javax.sound.midi.spi; " +
>>>>            "javax.sound.sampled; " +
>>>>            "javax.sound.sampled.spi; " +
>>>>            "javax.sql; " +
>>>>            "javax.xml.parsers; " +
>>>>            "junit.extensions; " +
>>>>            "junit.framework; " +
>>>>            "org.apache.commons.codec; " +
>>>>            "org.apache.commons.codec.binary; " +
>>>>            "org.apache.commons.codec.language; " +
>>>>            "org.apache.commons.codec.net; " +
>>>>            "org.apache.commons.httpclient; " +
>>>>            "org.apache.commons.httpclient.auth; " +
>>>>            "org.apache.commons.httpclient.cookie; " +
>>>>            "org.apache.commons.httpclient.methods; " +
>>>>            "org.apache.commons.httpclient.methods.multipart; " +
>>>>            "org.apache.commons.httpclient.params; " +
>>>>            "org.apache.commons.httpclient.protocol; " +
>>>>            "org.apache.commons.httpclient.util; " +
>>>>            "org.json; " +
>>>>            "org.w3c.dom; " +
>>>>            "org.xml.sax; " +
>>>>            "org.xml.sax.ext; " +
>>>>            "org.xml.sax.helpers; " +
>>>>            "version=1.6.0");
>>>>
>>>> Properties config = System.getProperties();
>>>> config.put("org.osgi.framework.startlevel.beginning",
>>>> Integer.toString(SkiftaService.SKIFTA_START_LEVEL));
>>>> config.put("org.osgi.framework.storage.clean", "onFirstInit");
>>>>
>>>> // make sure the OSGi cache dir is set to something sensible
>>>>
>>>> File cacheDir = this.getDir("osgi.cache", Context.MODE_PRIVATE);
>>>> Log.d(TAG, "setting osgi cache location to: " + cacheDir.getAbsolutePath());
>>>> config.put("org.osgi.framework.storage", cacheDir.getAbsolutePath());
>>>>
>>>>
>>>> // calculate the export packages list from the environment
>>>>
>>>> String sysPackages =
>>>> bootProps.getProperty("org.osgi.framework.system.packages.extra");
>>>> config.put("org.osgi.framework.system.packages",
>>>> ANDROID_FRAMEWORK_PACKAGES);
>>>> config.put("felix.log.level", "1");
>>>>
>>>> // Now create an instance of the framework with
>>>> // our configuration properties.
>>>>
>>>> Log.d(TAG, "Starting Felix...");
>>>> felix = new Felix(config);
>>>>
>>>> // Now start Felix instance.
>>>>
>>>> felix.start();
>>>>
>>>>
>>>> On 30/04/2010 11:30, "Bruce Jackson" <br...@qualcomm.com> wrote:
>>>>
>>>>> Actually, the problem is one of syntax, apparently. When you pass in the
>>>>> Properties object, the value against the key that was read from the file
>>>>> attached (i.e. the standard form of these files) it doesn't work.
>>>>>
>>>>> The list needs to be comma separated with no additional CR LF characters or
>>>>> the parser doesn't do the right thing.
>>>>>
>>>>> Clearly there must be some form of pre-parsing going on to handle the
>>>>> "standard" package lists in Felix.
>>>>>
>>>>>
>>>>> On 29/04/2010 17:30, "Karl Pauls" <ka...@gmail.com> wrote:
>>>>>
>>>>>> It should work, can you try to add a
>>>>>>
>>>>>> ; \
>>>>>>  version=\"1.6.0\"
>>>>>>
>>>>>> to the end of your package list? i.e.,
>>>>>>
>>>>>>  org.xml.sax.ext; \
>>>>>>  org.xml.sax.helpers; \
>>>>>>  version=\"1.6.0\"
>>>>>>
>>>>>>
>>>>>> regards,
>>>>>>
>>>>>> Karl
>>>>>>
>>>>>> On Wed, Apr 28, 2010 at 7:41 PM, Jackson, Bruce <br...@qualcomm.com>
>>>>>> wrote:
>>>>>>> Hi All
>>>>>>>
>>>>>>> I have Felix embedded into an Android app, and I'm trying to export the
>>>>>>> packages from the Android environment (e.g. android, android.app, etc)
>>>>>>> into
>>>>>>> Felix.
>>>>>>>
>>>>>>> I have a couple of questions: first, can I still use the pre-4.2
>>>>>>> constructor:
>>>>>>>
>>>>>>> Felix felix = new Felix(Properties props);
>>>>>>>
>>>>>>> ...and if I do so passing in a properties file which contains a
>>>>>>> semicolon-seperated list of packages as per the attached, should I see
>>>>>>> this
>>>>>>> working properly?
>>>>>>>
>>>>>>> Felix starts ok, but when I try to deploy any bundles to it (for example
>>>>>>> a
>>>>>>> dexified org.apache.log4j) I get a message fro the debugger when I call:
>>>>>>>
>>>>>>> BundleContent bc = felix.getBundleContent();
>>>>>>> bc.installBundle(name, inputStream);
>>>>>>>
>>>>>>> 04-28 18:31:45.716: ERROR/SkiftaService(6274): Unresolved constraint in
>>>>>>> bundle org.apache.log4j [1]: package; (package=javax.xml.parsers)
>>>>>>>
>>>>>>> ...which seems to suggest that it can't find the package.
>>>>>>>
>>>>>>> Any ideas?
>>>>>>>
>>>>>>> Thanks
>>>>>>>
>>>>>>> Bruce
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>>
>>
>
>



-- 
Karl Pauls
karlpauls@gmail.com

Re: org.osgi.framework.system.packages and Felix embedded in Android

Posted by "Jackson, Bruce" <br...@qualcomm.com>.
Further investigationf of the Android logs revels the following message
which appears just after calling Felix.start():

04-30 15:01:16.977: WARN/System.err(18939): Problem creating boot delegation
class loader: java.lang.reflect.InvocationTargetException
04-30 15:01:17.117: WARN/System.err(18939): ClassLoader =
dalvik.system.PathClassLoader - dalvik.system.PathClassLoader@46502120
04-30 15:01:17.187: WARN/System.err(245): java.io.IOException: Error running
exec(). Commands: [/system/xbin/su, 0, /system/bin/rm,
/data/local/tmp/com.skifta.android.apk] Working Directory: null Environment:
null
04-30 15:01:17.187: WARN/System.err(245):     at
java.lang.ProcessManager.exec(ProcessManager.java:196)
04-30 15:01:17.187: WARN/System.err(245):     at
java.lang.Runtime.exec(Runtime.java:225)
04-30 15:01:17.187: WARN/System.err(245):     at
java.lang.Runtime.exec(Runtime.java:313)
04-30 15:01:17.187: WARN/System.err(245):     at
java.lang.Runtime.exec(Runtime.java:246)
04-30 15:01:17.187: WARN/System.err(245):     at
com.htc.android.psclient.PackageInstallationReceiver.removeTempPackageFile(P
ackageInstallationReceiver.java:34)
04-30 15:01:17.187: WARN/System.err(245):     at
com.htc.android.psclient.PackageInstallationReceiver.access$000(PackageInsta
llationReceiver.java:8)
04-30 15:01:17.187: WARN/System.err(245):     at
com.htc.android.psclient.PackageInstallationReceiver$1.run(PackageInstallati
onReceiver.java:24)
04-30 15:01:17.187: WARN/System.err(245): Caused by: java.io.IOException: No
such file or directory
04-30 15:01:17.197: WARN/System.err(245):     at
java.lang.ProcessManager.exec(Native Method)
04-30 15:01:17.197: WARN/System.err(245):     at
java.lang.ProcessManager.exec(ProcessManager.java:194)
04-30 15:01:17.197: WARN/System.err(245):     ... 6 more



On 30/04/2010 14:50, "Bruce Jackson" <br...@qualcomm.com> wrote:

> I've added the lines:
> 
> // calculate the export packages list from the environment
> 
> config.put("org.osgi.framework.system.packages",
> ANDROID_FRAMEWORK_PACKAGES);
> config.put("org.osgi.framework.bundle.parent", "app");
> config.put("felix.log.level", "1");
> 
> and tried this with app, framework, boot and also ext, but I get the same
> result I'm afraid. I've certainly seen out on the web that people have done
> with with almost identical code on earlier version of Felix (I can't be sure
> of the exact Felix version, but the org.osgi.framework version was set to
> 1.2) but is it possible that has become broken in recent releases?
> 
> Thanks
> 
> Bruce
> 
> On 30/04/2010 13:34, "Karl Pauls" <ka...@gmail.com> wrote:
> 
>>  In case you have problems on android not finding classes that you are
>> making available via the system bundle, make sure you set the
>> org.osgi.framework.bundle.parent property to the correct value (either
>> app or framework, depends). i.e.,
>> 
>> org.osgi.framework.bundle.parent=app
>> 
>> or
>> 
>> org.osgi.framework.bundle.parent=framework
>> 
>> that should make it work.
>> 
>> regards,
>> 
>> Karl
>> 
>> On Fri, Apr 30, 2010 at 1:38 PM, Jackson, Bruce <br...@qualcomm.com> wrote:
>>> As a continuation to this mini-saga, I now have the initial problem (i.e.
>>> bundle resolution) fixed with the code below. When I add bundles to the
>>> running Felix framework, the resolve correctly, and start as long as their
>>> activator does not try to load any of the classes found in
>>> ANDROID_FRAMEWORK_PACKAGES, such as android.util.Log. If they do, I get a
>>> ClassNotFoundException:
>>> 
>>> 04-30 12:36:25.788: DEBUG/dalvikvm(16018): Making a copy of
>>> Lcom/skifta/android/mediaserver/AndroidTestImpl;.test4 code (68 bytes)
>>> 04-30 12:36:25.798: WARN/System.err(16018):
>>> org.osgi.framework.BundleException: Activator start error in bundle
>>> com.skifta.booster.cdir [4].
>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>> org.apache.felix.framework.Felix.activateBundle(Felix.java:1807)
>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>> org.apache.felix.framework.Felix.startBundle(Felix.java:1682)
>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>> org.apache.felix.framework.BundleImpl.start(BundleImpl.java:905)
>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>> org.apache.felix.framework.BundleImpl.start(BundleImpl.java:892)
>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>> com.skifta.android.client.SkiftaService.startOSGi(SkiftaService.java:401)
>>> ....
>>> 04-30 12:36:25.798: WARN/System.err(16018): Caused by:
>>> java.lang.NoClassDefFoundError: android.util.Log
>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>> 
com.skifta.android.mediaserver.AndroidTestImpl.test1(AndroidTestImpl.java:33>>>
)
>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>> com.skifta.booster.cdir.Activator.start(Activator.java:43)
>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>> 
org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.jav>>>
a
>>> :661)
>>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>>> org.apache.felix.framework.Felix.activateBundle(Felix.java:1760)
>>> 04-30 12:36:25.798: WARN/System.err(16018):     ... 17 more
>>> 
>>> 
>>> Any idea why the classloader is not allowing bundles I start to see the
>>> classes in the packages exported by the framework?
>>> 
>>> private static final String ANDROID_FRAMEWORK_PACKAGES =
>>> ("org.osgi.framework; version=1.4.0," +
>>>            "org.osgi.service.packageadmin; version=1.2.0," +
>>>            "org.osgi.service.startlevel; version=1.0.0," +
>>>            "org.osgi.service.url; version=1.0.0," +
>>>            "org.osgi.util.tracker," +
>>>            "android; " +
>>>            "android.app;" +
>>>            "android.content;" +
>>>            "android.database;" +
>>>            "android.database.sqlite;" +
>>>            "android.graphics; " +
>>>            "android.graphics.drawable; " +
>>>            "android.graphics.glutils; " +
>>>            "android.hardware; " +
>>>            "android.location; " +
>>>            "android.media; " +
>>>            "android.net; " +
>>>            "android.net.wifi; " +
>>>            "android.opengl; " +
>>>            "android.os; " +
>>>            "android.provider; " +
>>>            "android.sax; " +
>>>            "android.speech.recognition; " +
>>>            "android.telephony; " +
>>>            "android.telephony.gsm; " +
>>>            "android.text; " +
>>>            "android.text.method; " +
>>>            "android.text.style; " +
>>>            "android.text.util; " +
>>>            "android.util; " +
>>>            "android.view; " +
>>>            "android.view.animation; " +
>>>            "android.webkit; " +
>>>            "android.widget; " +
>>>            "com.google.android.maps; " +
>>>            "com.google.android.xmppService; " +
>>>            "javax.crypto; " +
>>>            "javax.crypto.interfaces; " +
>>>            "javax.crypto.spec; " +
>>>            "javax.microedition.khronos.opengles; " +
>>>            "javax.net; " +
>>>            "javax.net.ssl; " +
>>>            "javax.security.auth; " +
>>>            "javax.security.auth.callback; " +
>>>            "javax.security.auth.login; " +
>>>            "javax.security.auth.x500; " +
>>>            "javax.security.cert; " +
>>>            "javax.sound.midi; " +
>>>            "javax.sound.midi.spi; " +
>>>            "javax.sound.sampled; " +
>>>            "javax.sound.sampled.spi; " +
>>>            "javax.sql; " +
>>>            "javax.xml.parsers; " +
>>>            "junit.extensions; " +
>>>            "junit.framework; " +
>>>            "org.apache.commons.codec; " +
>>>            "org.apache.commons.codec.binary; " +
>>>            "org.apache.commons.codec.language; " +
>>>            "org.apache.commons.codec.net; " +
>>>            "org.apache.commons.httpclient; " +
>>>            "org.apache.commons.httpclient.auth; " +
>>>            "org.apache.commons.httpclient.cookie; " +
>>>            "org.apache.commons.httpclient.methods; " +
>>>            "org.apache.commons.httpclient.methods.multipart; " +
>>>            "org.apache.commons.httpclient.params; " +
>>>            "org.apache.commons.httpclient.protocol; " +
>>>            "org.apache.commons.httpclient.util; " +
>>>            "org.json; " +
>>>            "org.w3c.dom; " +
>>>            "org.xml.sax; " +
>>>            "org.xml.sax.ext; " +
>>>            "org.xml.sax.helpers; " +
>>>            "version=1.6.0");
>>> 
>>> Properties config = System.getProperties();
>>> config.put("org.osgi.framework.startlevel.beginning",
>>> Integer.toString(SkiftaService.SKIFTA_START_LEVEL));
>>> config.put("org.osgi.framework.storage.clean", "onFirstInit");
>>> 
>>> // make sure the OSGi cache dir is set to something sensible
>>> 
>>> File cacheDir = this.getDir("osgi.cache", Context.MODE_PRIVATE);
>>> Log.d(TAG, "setting osgi cache location to: " + cacheDir.getAbsolutePath());
>>> config.put("org.osgi.framework.storage", cacheDir.getAbsolutePath());
>>> 
>>> 
>>> // calculate the export packages list from the environment
>>> 
>>> String sysPackages =
>>> bootProps.getProperty("org.osgi.framework.system.packages.extra");
>>> config.put("org.osgi.framework.system.packages",
>>> ANDROID_FRAMEWORK_PACKAGES);
>>> config.put("felix.log.level", "1");
>>> 
>>> // Now create an instance of the framework with
>>> // our configuration properties.
>>> 
>>> Log.d(TAG, "Starting Felix...");
>>> felix = new Felix(config);
>>> 
>>> // Now start Felix instance.
>>> 
>>> felix.start();
>>> 
>>> 
>>> On 30/04/2010 11:30, "Bruce Jackson" <br...@qualcomm.com> wrote:
>>> 
>>>> Actually, the problem is one of syntax, apparently. When you pass in the
>>>> Properties object, the value against the key that was read from the file
>>>> attached (i.e. the standard form of these files) it doesn't work.
>>>> 
>>>> The list needs to be comma separated with no additional CR LF characters or
>>>> the parser doesn't do the right thing.
>>>> 
>>>> Clearly there must be some form of pre-parsing going on to handle the
>>>> "standard" package lists in Felix.
>>>> 
>>>> 
>>>> On 29/04/2010 17:30, "Karl Pauls" <ka...@gmail.com> wrote:
>>>> 
>>>>> It should work, can you try to add a
>>>>> 
>>>>> ; \
>>>>>  version=\"1.6.0\"
>>>>> 
>>>>> to the end of your package list? i.e.,
>>>>> 
>>>>>  org.xml.sax.ext; \
>>>>>  org.xml.sax.helpers; \
>>>>>  version=\"1.6.0\"
>>>>> 
>>>>> 
>>>>> regards,
>>>>> 
>>>>> Karl
>>>>> 
>>>>> On Wed, Apr 28, 2010 at 7:41 PM, Jackson, Bruce <br...@qualcomm.com>
>>>>> wrote:
>>>>>> Hi All
>>>>>> 
>>>>>> I have Felix embedded into an Android app, and I'm trying to export the
>>>>>> packages from the Android environment (e.g. android, android.app, etc)
>>>>>> into
>>>>>> Felix.
>>>>>> 
>>>>>> I have a couple of questions: first, can I still use the pre-4.2
>>>>>> constructor:
>>>>>> 
>>>>>> Felix felix = new Felix(Properties props);
>>>>>> 
>>>>>> ...and if I do so passing in a properties file which contains a
>>>>>> semicolon-seperated list of packages as per the attached, should I see
>>>>>> this
>>>>>> working properly?
>>>>>> 
>>>>>> Felix starts ok, but when I try to deploy any bundles to it (for example
>>>>>> a
>>>>>> dexified org.apache.log4j) I get a message fro the debugger when I call:
>>>>>> 
>>>>>> BundleContent bc = felix.getBundleContent();
>>>>>> bc.installBundle(name, inputStream);
>>>>>> 
>>>>>> 04-28 18:31:45.716: ERROR/SkiftaService(6274): Unresolved constraint in
>>>>>> bundle org.apache.log4j [1]: package; (package=javax.xml.parsers)
>>>>>> 
>>>>>> ...which seems to suggest that it can't find the package.
>>>>>> 
>>>>>> Any ideas?
>>>>>> 
>>>>>> Thanks
>>>>>> 
>>>>>> Bruce
>>>>>> 
>>>>>> 
>>>>> 
>>>>> 
>>>> 
>>> 
>> 
>> 
> 


Re: org.osgi.framework.system.packages and Felix embedded in Android

Posted by "Jackson, Bruce" <br...@qualcomm.com>.
I've added the lines:

// calculate the export packages list from the environment

config.put("org.osgi.framework.system.packages",
ANDROID_FRAMEWORK_PACKAGES);
config.put("org.osgi.framework.bundle.parent", "app");
config.put("felix.log.level", "1");

and tried this with app, framework, boot and also ext, but I get the same
result I'm afraid. I've certainly seen out on the web that people have done
with with almost identical code on earlier version of Felix (I can't be sure
of the exact Felix version, but the org.osgi.framework version was set to
1.2) but is it possible that has become broken in recent releases?

Thanks

Bruce

On 30/04/2010 13:34, "Karl Pauls" <ka...@gmail.com> wrote:

>  In case you have problems on android not finding classes that you are
> making available via the system bundle, make sure you set the
> org.osgi.framework.bundle.parent property to the correct value (either
> app or framework, depends). i.e.,
> 
> org.osgi.framework.bundle.parent=app
> 
> or
> 
> org.osgi.framework.bundle.parent=framework
> 
> that should make it work.
> 
> regards,
> 
> Karl
> 
> On Fri, Apr 30, 2010 at 1:38 PM, Jackson, Bruce <br...@qualcomm.com> wrote:
>> As a continuation to this mini-saga, I now have the initial problem (i.e.
>> bundle resolution) fixed with the code below. When I add bundles to the
>> running Felix framework, the resolve correctly, and start as long as their
>> activator does not try to load any of the classes found in
>> ANDROID_FRAMEWORK_PACKAGES, such as android.util.Log. If they do, I get a
>> ClassNotFoundException:
>> 
>> 04-30 12:36:25.788: DEBUG/dalvikvm(16018): Making a copy of
>> Lcom/skifta/android/mediaserver/AndroidTestImpl;.test4 code (68 bytes)
>> 04-30 12:36:25.798: WARN/System.err(16018):
>> org.osgi.framework.BundleException: Activator start error in bundle
>> com.skifta.booster.cdir [4].
>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>> org.apache.felix.framework.Felix.activateBundle(Felix.java:1807)
>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>> org.apache.felix.framework.Felix.startBundle(Felix.java:1682)
>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>> org.apache.felix.framework.BundleImpl.start(BundleImpl.java:905)
>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>> org.apache.felix.framework.BundleImpl.start(BundleImpl.java:892)
>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>> com.skifta.android.client.SkiftaService.startOSGi(SkiftaService.java:401)
>> ....
>> 04-30 12:36:25.798: WARN/System.err(16018): Caused by:
>> java.lang.NoClassDefFoundError: android.util.Log
>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>> com.skifta.android.mediaserver.AndroidTestImpl.test1(AndroidTestImpl.java:33)
>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>> com.skifta.booster.cdir.Activator.start(Activator.java:43)
>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>> org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java
>> :661)
>> 04-30 12:36:25.798: WARN/System.err(16018):     at
>> org.apache.felix.framework.Felix.activateBundle(Felix.java:1760)
>> 04-30 12:36:25.798: WARN/System.err(16018):     ... 17 more
>> 
>> 
>> Any idea why the classloader is not allowing bundles I start to see the
>> classes in the packages exported by the framework?
>> 
>> private static final String ANDROID_FRAMEWORK_PACKAGES =
>> ("org.osgi.framework; version=1.4.0," +
>>            "org.osgi.service.packageadmin; version=1.2.0," +
>>            "org.osgi.service.startlevel; version=1.0.0," +
>>            "org.osgi.service.url; version=1.0.0," +
>>            "org.osgi.util.tracker," +
>>            "android; " +
>>            "android.app;" +
>>            "android.content;" +
>>            "android.database;" +
>>            "android.database.sqlite;" +
>>            "android.graphics; " +
>>            "android.graphics.drawable; " +
>>            "android.graphics.glutils; " +
>>            "android.hardware; " +
>>            "android.location; " +
>>            "android.media; " +
>>            "android.net; " +
>>            "android.net.wifi; " +
>>            "android.opengl; " +
>>            "android.os; " +
>>            "android.provider; " +
>>            "android.sax; " +
>>            "android.speech.recognition; " +
>>            "android.telephony; " +
>>            "android.telephony.gsm; " +
>>            "android.text; " +
>>            "android.text.method; " +
>>            "android.text.style; " +
>>            "android.text.util; " +
>>            "android.util; " +
>>            "android.view; " +
>>            "android.view.animation; " +
>>            "android.webkit; " +
>>            "android.widget; " +
>>            "com.google.android.maps; " +
>>            "com.google.android.xmppService; " +
>>            "javax.crypto; " +
>>            "javax.crypto.interfaces; " +
>>            "javax.crypto.spec; " +
>>            "javax.microedition.khronos.opengles; " +
>>            "javax.net; " +
>>            "javax.net.ssl; " +
>>            "javax.security.auth; " +
>>            "javax.security.auth.callback; " +
>>            "javax.security.auth.login; " +
>>            "javax.security.auth.x500; " +
>>            "javax.security.cert; " +
>>            "javax.sound.midi; " +
>>            "javax.sound.midi.spi; " +
>>            "javax.sound.sampled; " +
>>            "javax.sound.sampled.spi; " +
>>            "javax.sql; " +
>>            "javax.xml.parsers; " +
>>            "junit.extensions; " +
>>            "junit.framework; " +
>>            "org.apache.commons.codec; " +
>>            "org.apache.commons.codec.binary; " +
>>            "org.apache.commons.codec.language; " +
>>            "org.apache.commons.codec.net; " +
>>            "org.apache.commons.httpclient; " +
>>            "org.apache.commons.httpclient.auth; " +
>>            "org.apache.commons.httpclient.cookie; " +
>>            "org.apache.commons.httpclient.methods; " +
>>            "org.apache.commons.httpclient.methods.multipart; " +
>>            "org.apache.commons.httpclient.params; " +
>>            "org.apache.commons.httpclient.protocol; " +
>>            "org.apache.commons.httpclient.util; " +
>>            "org.json; " +
>>            "org.w3c.dom; " +
>>            "org.xml.sax; " +
>>            "org.xml.sax.ext; " +
>>            "org.xml.sax.helpers; " +
>>            "version=1.6.0");
>> 
>> Properties config = System.getProperties();
>> config.put("org.osgi.framework.startlevel.beginning",
>> Integer.toString(SkiftaService.SKIFTA_START_LEVEL));
>> config.put("org.osgi.framework.storage.clean", "onFirstInit");
>> 
>> // make sure the OSGi cache dir is set to something sensible
>> 
>> File cacheDir = this.getDir("osgi.cache", Context.MODE_PRIVATE);
>> Log.d(TAG, "setting osgi cache location to: " + cacheDir.getAbsolutePath());
>> config.put("org.osgi.framework.storage", cacheDir.getAbsolutePath());
>> 
>> 
>> // calculate the export packages list from the environment
>> 
>> String sysPackages =
>> bootProps.getProperty("org.osgi.framework.system.packages.extra");
>> config.put("org.osgi.framework.system.packages", ANDROID_FRAMEWORK_PACKAGES);
>> config.put("felix.log.level", "1");
>> 
>> // Now create an instance of the framework with
>> // our configuration properties.
>> 
>> Log.d(TAG, "Starting Felix...");
>> felix = new Felix(config);
>> 
>> // Now start Felix instance.
>> 
>> felix.start();
>> 
>> 
>> On 30/04/2010 11:30, "Bruce Jackson" <br...@qualcomm.com> wrote:
>> 
>>> Actually, the problem is one of syntax, apparently. When you pass in the
>>> Properties object, the value against the key that was read from the file
>>> attached (i.e. the standard form of these files) it doesn't work.
>>> 
>>> The list needs to be comma separated with no additional CR LF characters or
>>> the parser doesn't do the right thing.
>>> 
>>> Clearly there must be some form of pre-parsing going on to handle the
>>> "standard" package lists in Felix.
>>> 
>>> 
>>> On 29/04/2010 17:30, "Karl Pauls" <ka...@gmail.com> wrote:
>>> 
>>>> It should work, can you try to add a
>>>> 
>>>> ; \
>>>>  version=\"1.6.0\"
>>>> 
>>>> to the end of your package list? i.e.,
>>>> 
>>>>  org.xml.sax.ext; \
>>>>  org.xml.sax.helpers; \
>>>>  version=\"1.6.0\"
>>>> 
>>>> 
>>>> regards,
>>>> 
>>>> Karl
>>>> 
>>>> On Wed, Apr 28, 2010 at 7:41 PM, Jackson, Bruce <br...@qualcomm.com>
>>>> wrote:
>>>>> Hi All
>>>>> 
>>>>> I have Felix embedded into an Android app, and I'm trying to export the
>>>>> packages from the Android environment (e.g. android, android.app, etc)
>>>>> into
>>>>> Felix.
>>>>> 
>>>>> I have a couple of questions: first, can I still use the pre-4.2
>>>>> constructor:
>>>>> 
>>>>> Felix felix = new Felix(Properties props);
>>>>> 
>>>>> ...and if I do so passing in a properties file which contains a
>>>>> semicolon-seperated list of packages as per the attached, should I see
>>>>> this
>>>>> working properly?
>>>>> 
>>>>> Felix starts ok, but when I try to deploy any bundles to it (for example a
>>>>> dexified org.apache.log4j) I get a message fro the debugger when I call:
>>>>> 
>>>>> BundleContent bc = felix.getBundleContent();
>>>>> bc.installBundle(name, inputStream);
>>>>> 
>>>>> 04-28 18:31:45.716: ERROR/SkiftaService(6274): Unresolved constraint in
>>>>> bundle org.apache.log4j [1]: package; (package=javax.xml.parsers)
>>>>> 
>>>>> ...which seems to suggest that it can't find the package.
>>>>> 
>>>>> Any ideas?
>>>>> 
>>>>> Thanks
>>>>> 
>>>>> Bruce
>>>>> 
>>>>> 
>>>> 
>>>> 
>>> 
>> 
> 
> 


Re: org.osgi.framework.system.packages and Felix embedded in Android

Posted by Karl Pauls <ka...@gmail.com>.
 In case you have problems on android not finding classes that you are
making available via the system bundle, make sure you set the
org.osgi.framework.bundle.parent property to the correct value (either
app or framework, depends). i.e.,

org.osgi.framework.bundle.parent=app

or

org.osgi.framework.bundle.parent=framework

that should make it work.

regards,

Karl

On Fri, Apr 30, 2010 at 1:38 PM, Jackson, Bruce <br...@qualcomm.com> wrote:
> As a continuation to this mini-saga, I now have the initial problem (i.e. bundle resolution) fixed with the code below. When I add bundles to the running Felix framework, the resolve correctly, and start as long as their activator does not try to load any of the classes found in ANDROID_FRAMEWORK_PACKAGES, such as android.util.Log. If they do, I get a ClassNotFoundException:
>
> 04-30 12:36:25.788: DEBUG/dalvikvm(16018): Making a copy of Lcom/skifta/android/mediaserver/AndroidTestImpl;.test4 code (68 bytes)
> 04-30 12:36:25.798: WARN/System.err(16018): org.osgi.framework.BundleException: Activator start error in bundle com.skifta.booster.cdir [4].
> 04-30 12:36:25.798: WARN/System.err(16018):     at org.apache.felix.framework.Felix.activateBundle(Felix.java:1807)
> 04-30 12:36:25.798: WARN/System.err(16018):     at org.apache.felix.framework.Felix.startBundle(Felix.java:1682)
> 04-30 12:36:25.798: WARN/System.err(16018):     at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:905)
> 04-30 12:36:25.798: WARN/System.err(16018):     at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:892)
> 04-30 12:36:25.798: WARN/System.err(16018):     at com.skifta.android.client.SkiftaService.startOSGi(SkiftaService.java:401)
> ....
> 04-30 12:36:25.798: WARN/System.err(16018): Caused by: java.lang.NoClassDefFoundError: android.util.Log
> 04-30 12:36:25.798: WARN/System.err(16018):     at com.skifta.android.mediaserver.AndroidTestImpl.test1(AndroidTestImpl.java:33)
> 04-30 12:36:25.798: WARN/System.err(16018):     at com.skifta.booster.cdir.Activator.start(Activator.java:43)
> 04-30 12:36:25.798: WARN/System.err(16018):     at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:661)
> 04-30 12:36:25.798: WARN/System.err(16018):     at org.apache.felix.framework.Felix.activateBundle(Felix.java:1760)
> 04-30 12:36:25.798: WARN/System.err(16018):     ... 17 more
>
>
> Any idea why the classloader is not allowing bundles I start to see the classes in the packages exported by the framework?
>
> private static final String ANDROID_FRAMEWORK_PACKAGES = ("org.osgi.framework; version=1.4.0," +
>            "org.osgi.service.packageadmin; version=1.2.0," +
>            "org.osgi.service.startlevel; version=1.0.0," +
>            "org.osgi.service.url; version=1.0.0," +
>            "org.osgi.util.tracker," +
>            "android; " +
>            "android.app;" +
>            "android.content;" +
>            "android.database;" +
>            "android.database.sqlite;" +
>            "android.graphics; " +
>            "android.graphics.drawable; " +
>            "android.graphics.glutils; " +
>            "android.hardware; " +
>            "android.location; " +
>            "android.media; " +
>            "android.net; " +
>            "android.net.wifi; " +
>            "android.opengl; " +
>            "android.os; " +
>            "android.provider; " +
>            "android.sax; " +
>            "android.speech.recognition; " +
>            "android.telephony; " +
>            "android.telephony.gsm; " +
>            "android.text; " +
>            "android.text.method; " +
>            "android.text.style; " +
>            "android.text.util; " +
>            "android.util; " +
>            "android.view; " +
>            "android.view.animation; " +
>            "android.webkit; " +
>            "android.widget; " +
>            "com.google.android.maps; " +
>            "com.google.android.xmppService; " +
>            "javax.crypto; " +
>            "javax.crypto.interfaces; " +
>            "javax.crypto.spec; " +
>            "javax.microedition.khronos.opengles; " +
>            "javax.net; " +
>            "javax.net.ssl; " +
>            "javax.security.auth; " +
>            "javax.security.auth.callback; " +
>            "javax.security.auth.login; " +
>            "javax.security.auth.x500; " +
>            "javax.security.cert; " +
>            "javax.sound.midi; " +
>            "javax.sound.midi.spi; " +
>            "javax.sound.sampled; " +
>            "javax.sound.sampled.spi; " +
>            "javax.sql; " +
>            "javax.xml.parsers; " +
>            "junit.extensions; " +
>            "junit.framework; " +
>            "org.apache.commons.codec; " +
>            "org.apache.commons.codec.binary; " +
>            "org.apache.commons.codec.language; " +
>            "org.apache.commons.codec.net; " +
>            "org.apache.commons.httpclient; " +
>            "org.apache.commons.httpclient.auth; " +
>            "org.apache.commons.httpclient.cookie; " +
>            "org.apache.commons.httpclient.methods; " +
>            "org.apache.commons.httpclient.methods.multipart; " +
>            "org.apache.commons.httpclient.params; " +
>            "org.apache.commons.httpclient.protocol; " +
>            "org.apache.commons.httpclient.util; " +
>            "org.json; " +
>            "org.w3c.dom; " +
>            "org.xml.sax; " +
>            "org.xml.sax.ext; " +
>            "org.xml.sax.helpers; " +
>            "version=1.6.0");
>
> Properties config = System.getProperties();
> config.put("org.osgi.framework.startlevel.beginning", Integer.toString(SkiftaService.SKIFTA_START_LEVEL));
> config.put("org.osgi.framework.storage.clean", "onFirstInit");
>
> // make sure the OSGi cache dir is set to something sensible
>
> File cacheDir = this.getDir("osgi.cache", Context.MODE_PRIVATE);
> Log.d(TAG, "setting osgi cache location to: " + cacheDir.getAbsolutePath());
> config.put("org.osgi.framework.storage", cacheDir.getAbsolutePath());
>
>
> // calculate the export packages list from the environment
>
> String sysPackages = bootProps.getProperty("org.osgi.framework.system.packages.extra");
> config.put("org.osgi.framework.system.packages", ANDROID_FRAMEWORK_PACKAGES);
> config.put("felix.log.level", "1");
>
> // Now create an instance of the framework with
> // our configuration properties.
>
> Log.d(TAG, "Starting Felix...");
> felix = new Felix(config);
>
> // Now start Felix instance.
>
> felix.start();
>
>
> On 30/04/2010 11:30, "Bruce Jackson" <br...@qualcomm.com> wrote:
>
>> Actually, the problem is one of syntax, apparently. When you pass in the
>> Properties object, the value against the key that was read from the file
>> attached (i.e. the standard form of these files) it doesn't work.
>>
>> The list needs to be comma separated with no additional CR LF characters or
>> the parser doesn't do the right thing.
>>
>> Clearly there must be some form of pre-parsing going on to handle the
>> "standard" package lists in Felix.
>>
>>
>> On 29/04/2010 17:30, "Karl Pauls" <ka...@gmail.com> wrote:
>>
>>> It should work, can you try to add a
>>>
>>> ; \
>>>  version=\"1.6.0\"
>>>
>>> to the end of your package list? i.e.,
>>>
>>>  org.xml.sax.ext; \
>>>  org.xml.sax.helpers; \
>>>  version=\"1.6.0\"
>>>
>>>
>>> regards,
>>>
>>> Karl
>>>
>>> On Wed, Apr 28, 2010 at 7:41 PM, Jackson, Bruce <br...@qualcomm.com> wrote:
>>>> Hi All
>>>>
>>>> I have Felix embedded into an Android app, and I'm trying to export the
>>>> packages from the Android environment (e.g. android, android.app, etc) into
>>>> Felix.
>>>>
>>>> I have a couple of questions: first, can I still use the pre-4.2
>>>> constructor:
>>>>
>>>> Felix felix = new Felix(Properties props);
>>>>
>>>> ...and if I do so passing in a properties file which contains a
>>>> semicolon-seperated list of packages as per the attached, should I see this
>>>> working properly?
>>>>
>>>> Felix starts ok, but when I try to deploy any bundles to it (for example a
>>>> dexified org.apache.log4j) I get a message fro the debugger when I call:
>>>>
>>>> BundleContent bc = felix.getBundleContent();
>>>> bc.installBundle(name, inputStream);
>>>>
>>>> 04-28 18:31:45.716: ERROR/SkiftaService(6274): Unresolved constraint in
>>>> bundle org.apache.log4j [1]: package; (package=javax.xml.parsers)
>>>>
>>>> ...which seems to suggest that it can't find the package.
>>>>
>>>> Any ideas?
>>>>
>>>> Thanks
>>>>
>>>> Bruce
>>>>
>>>>
>>>
>>>
>>
>



-- 
Karl Pauls
karlpauls@gmail.com

Re: org.osgi.framework.system.packages and Felix embedded in Android

Posted by "Jackson, Bruce" <br...@qualcomm.com>.
As a continuation to this mini-saga, I now have the initial problem (i.e. bundle resolution) fixed with the code below. When I add bundles to the running Felix framework, the resolve correctly, and start as long as their activator does not try to load any of the classes found in ANDROID_FRAMEWORK_PACKAGES, such as android.util.Log. If they do, I get a ClassNotFoundException:

04-30 12:36:25.788: DEBUG/dalvikvm(16018): Making a copy of Lcom/skifta/android/mediaserver/AndroidTestImpl;.test4 code (68 bytes)
04-30 12:36:25.798: WARN/System.err(16018): org.osgi.framework.BundleException: Activator start error in bundle com.skifta.booster.cdir [4].
04-30 12:36:25.798: WARN/System.err(16018):     at org.apache.felix.framework.Felix.activateBundle(Felix.java:1807)
04-30 12:36:25.798: WARN/System.err(16018):     at org.apache.felix.framework.Felix.startBundle(Felix.java:1682)
04-30 12:36:25.798: WARN/System.err(16018):     at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:905)
04-30 12:36:25.798: WARN/System.err(16018):     at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:892)
04-30 12:36:25.798: WARN/System.err(16018):     at com.skifta.android.client.SkiftaService.startOSGi(SkiftaService.java:401)
....
04-30 12:36:25.798: WARN/System.err(16018): Caused by: java.lang.NoClassDefFoundError: android.util.Log
04-30 12:36:25.798: WARN/System.err(16018):     at com.skifta.android.mediaserver.AndroidTestImpl.test1(AndroidTestImpl.java:33)
04-30 12:36:25.798: WARN/System.err(16018):     at com.skifta.booster.cdir.Activator.start(Activator.java:43)
04-30 12:36:25.798: WARN/System.err(16018):     at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:661)
04-30 12:36:25.798: WARN/System.err(16018):     at org.apache.felix.framework.Felix.activateBundle(Felix.java:1760)
04-30 12:36:25.798: WARN/System.err(16018):     ... 17 more


Any idea why the classloader is not allowing bundles I start to see the classes in the packages exported by the framework?

private static final String ANDROID_FRAMEWORK_PACKAGES = ("org.osgi.framework; version=1.4.0," +
            "org.osgi.service.packageadmin; version=1.2.0," +
            "org.osgi.service.startlevel; version=1.0.0," +
            "org.osgi.service.url; version=1.0.0," +
            "org.osgi.util.tracker," +
            "android; " +
            "android.app;" +
            "android.content;" +
            "android.database;" +
            "android.database.sqlite;" +
            "android.graphics; " +
            "android.graphics.drawable; " +
            "android.graphics.glutils; " +
            "android.hardware; " +
            "android.location; " +
            "android.media; " +
            "android.net; " +
            "android.net.wifi; " +
            "android.opengl; " +
            "android.os; " +
            "android.provider; " +
            "android.sax; " +
            "android.speech.recognition; " +
            "android.telephony; " +
            "android.telephony.gsm; " +
            "android.text; " +
            "android.text.method; " +
            "android.text.style; " +
            "android.text.util; " +
            "android.util; " +
            "android.view; " +
            "android.view.animation; " +
            "android.webkit; " +
            "android.widget; " +
            "com.google.android.maps; " +
            "com.google.android.xmppService; " +
            "javax.crypto; " +
            "javax.crypto.interfaces; " +
            "javax.crypto.spec; " +
            "javax.microedition.khronos.opengles; " +
            "javax.net; " +
            "javax.net.ssl; " +
            "javax.security.auth; " +
            "javax.security.auth.callback; " +
            "javax.security.auth.login; " +
            "javax.security.auth.x500; " +
            "javax.security.cert; " +
            "javax.sound.midi; " +
            "javax.sound.midi.spi; " +
            "javax.sound.sampled; " +
            "javax.sound.sampled.spi; " +
            "javax.sql; " +
            "javax.xml.parsers; " +
            "junit.extensions; " +
            "junit.framework; " +
            "org.apache.commons.codec; " +
            "org.apache.commons.codec.binary; " +
            "org.apache.commons.codec.language; " +
            "org.apache.commons.codec.net; " +
            "org.apache.commons.httpclient; " +
            "org.apache.commons.httpclient.auth; " +
            "org.apache.commons.httpclient.cookie; " +
            "org.apache.commons.httpclient.methods; " +
            "org.apache.commons.httpclient.methods.multipart; " +
            "org.apache.commons.httpclient.params; " +
            "org.apache.commons.httpclient.protocol; " +
            "org.apache.commons.httpclient.util; " +
            "org.json; " +
            "org.w3c.dom; " +
            "org.xml.sax; " +
            "org.xml.sax.ext; " +
            "org.xml.sax.helpers; " +
            "version=1.6.0");

Properties config = System.getProperties();
config.put("org.osgi.framework.startlevel.beginning", Integer.toString(SkiftaService.SKIFTA_START_LEVEL));
config.put("org.osgi.framework.storage.clean", "onFirstInit");

// make sure the OSGi cache dir is set to something sensible

File cacheDir = this.getDir("osgi.cache", Context.MODE_PRIVATE);
Log.d(TAG, "setting osgi cache location to: " + cacheDir.getAbsolutePath());
config.put("org.osgi.framework.storage", cacheDir.getAbsolutePath());


// calculate the export packages list from the environment

String sysPackages = bootProps.getProperty("org.osgi.framework.system.packages.extra");
config.put("org.osgi.framework.system.packages", ANDROID_FRAMEWORK_PACKAGES);
config.put("felix.log.level", "1");

// Now create an instance of the framework with
// our configuration properties.

Log.d(TAG, "Starting Felix...");
felix = new Felix(config);

// Now start Felix instance.

felix.start();


On 30/04/2010 11:30, "Bruce Jackson" <br...@qualcomm.com> wrote:

> Actually, the problem is one of syntax, apparently. When you pass in the
> Properties object, the value against the key that was read from the file
> attached (i.e. the standard form of these files) it doesn't work.
>
> The list needs to be comma separated with no additional CR LF characters or
> the parser doesn't do the right thing.
>
> Clearly there must be some form of pre-parsing going on to handle the
> "standard" package lists in Felix.
>
>
> On 29/04/2010 17:30, "Karl Pauls" <ka...@gmail.com> wrote:
>
>> It should work, can you try to add a
>>
>> ; \
>>  version=\"1.6.0\"
>>
>> to the end of your package list? i.e.,
>>
>>  org.xml.sax.ext; \
>>  org.xml.sax.helpers; \
>>  version=\"1.6.0\"
>>
>>
>> regards,
>>
>> Karl
>>
>> On Wed, Apr 28, 2010 at 7:41 PM, Jackson, Bruce <br...@qualcomm.com> wrote:
>>> Hi All
>>>
>>> I have Felix embedded into an Android app, and I'm trying to export the
>>> packages from the Android environment (e.g. android, android.app, etc) into
>>> Felix.
>>>
>>> I have a couple of questions: first, can I still use the pre-4.2
>>> constructor:
>>>
>>> Felix felix = new Felix(Properties props);
>>>
>>> ...and if I do so passing in a properties file which contains a
>>> semicolon-seperated list of packages as per the attached, should I see this
>>> working properly?
>>>
>>> Felix starts ok, but when I try to deploy any bundles to it (for example a
>>> dexified org.apache.log4j) I get a message fro the debugger when I call:
>>>
>>> BundleContent bc = felix.getBundleContent();
>>> bc.installBundle(name, inputStream);
>>>
>>> 04-28 18:31:45.716: ERROR/SkiftaService(6274): Unresolved constraint in
>>> bundle org.apache.log4j [1]: package; (package=javax.xml.parsers)
>>>
>>> ...which seems to suggest that it can't find the package.
>>>
>>> Any ideas?
>>>
>>> Thanks
>>>
>>> Bruce
>>>
>>>
>>
>>
>

Re: org.osgi.framework.system.packages and Felix embedded in Android

Posted by "Jackson, Bruce" <br...@qualcomm.com>.
Actually, the problem is one of syntax, apparently. When you pass in the
Properties object, the value against the key that was read from the file
attached (i.e. the standard form of these files) it doesn't work.

The list needs to be comma separated with no additional CR LF characters or
the parser doesn't do the right thing.

Clearly there must be some form of pre-parsing going on to handle the
"standard" package lists in Felix.


On 29/04/2010 17:30, "Karl Pauls" <ka...@gmail.com> wrote:

> It should work, can you try to add a
> 
> ; \
>  version=\"1.6.0\"
> 
> to the end of your package list? i.e.,
> 
>  org.xml.sax.ext; \
>  org.xml.sax.helpers; \
>  version=\"1.6.0\"
> 
> 
> regards,
> 
> Karl
> 
> On Wed, Apr 28, 2010 at 7:41 PM, Jackson, Bruce <br...@qualcomm.com> wrote:
>> Hi All
>> 
>> I have Felix embedded into an Android app, and I'm trying to export the
>> packages from the Android environment (e.g. android, android.app, etc) into
>> Felix.
>> 
>> I have a couple of questions: first, can I still use the pre-4.2
>> constructor:
>> 
>> Felix felix = new Felix(Properties props);
>> 
>> ...and if I do so passing in a properties file which contains a
>> semicolon-seperated list of packages as per the attached, should I see this
>> working properly?
>> 
>> Felix starts ok, but when I try to deploy any bundles to it (for example a
>> dexified org.apache.log4j) I get a message fro the debugger when I call:
>> 
>> BundleContent bc = felix.getBundleContent();
>> bc.installBundle(name, inputStream);
>> 
>> 04-28 18:31:45.716: ERROR/SkiftaService(6274): Unresolved constraint in
>> bundle org.apache.log4j [1]: package; (package=javax.xml.parsers)
>> 
>> ...which seems to suggest that it can't find the package.
>> 
>> Any ideas?
>> 
>> Thanks
>> 
>> Bruce
>> 
>> 
> 
> 


Re: org.osgi.framework.system.packages and Felix embedded in Android

Posted by Karl Pauls <ka...@gmail.com>.
It should work, can you try to add a

; \
 version=\"1.6.0\"

to the end of your package list? i.e.,

 org.xml.sax.ext; \
 org.xml.sax.helpers; \
 version=\"1.6.0\"


regards,

Karl

On Wed, Apr 28, 2010 at 7:41 PM, Jackson, Bruce <br...@qualcomm.com> wrote:
> Hi All
>
> I have Felix embedded into an Android app, and I'm trying to export the
> packages from the Android environment (e.g. android, android.app, etc) into
> Felix.
>
> I have a couple of questions: first, can I still use the pre-4.2
> constructor:
>
> Felix felix = new Felix(Properties props);
>
> ...and if I do so passing in a properties file which contains a
> semicolon-seperated list of packages as per the attached, should I see this
> working properly?
>
> Felix starts ok, but when I try to deploy any bundles to it (for example a
> dexified org.apache.log4j) I get a message fro the debugger when I call:
>
> BundleContent bc = felix.getBundleContent();
> bc.installBundle(name, inputStream);
>
> 04-28 18:31:45.716: ERROR/SkiftaService(6274): Unresolved constraint in
> bundle org.apache.log4j [1]: package; (package=javax.xml.parsers)
>
> ...which seems to suggest that it can't find the package.
>
> Any ideas?
>
> Thanks
>
> Bruce
>
>



-- 
Karl Pauls
karlpauls@gmail.com

Re: org.osgi.framework.system.packages and Felix embedded in Android

Posted by Karl Pauls <ka...@gmail.com>.
Can you set the log level to debug:

felix.log.level=4

and give us the output of system.out?

regards,

Karl

On Wed, Apr 28, 2010 at 7:41 PM, Jackson, Bruce <br...@qualcomm.com> wrote:
> Hi All
>
> I have Felix embedded into an Android app, and I'm trying to export the
> packages from the Android environment (e.g. android, android.app, etc) into
> Felix.
>
> I have a couple of questions: first, can I still use the pre-4.2
> constructor:
>
> Felix felix = new Felix(Properties props);
>
> ...and if I do so passing in a properties file which contains a
> semicolon-seperated list of packages as per the attached, should I see this
> working properly?
>
> Felix starts ok, but when I try to deploy any bundles to it (for example a
> dexified org.apache.log4j) I get a message fro the debugger when I call:
>
> BundleContent bc = felix.getBundleContent();
> bc.installBundle(name, inputStream);
>
> 04-28 18:31:45.716: ERROR/SkiftaService(6274): Unresolved constraint in
> bundle org.apache.log4j [1]: package; (package=javax.xml.parsers)
>
> ...which seems to suggest that it can't find the package.
>
> Any ideas?
>
> Thanks
>
> Bruce
>
>



-- 
Karl Pauls
karlpauls@gmail.com

Re: org.osgi.framework.system.packages and Felix embedded in Android

Posted by "Richard S. Hall" <he...@ungoverned.org>.

On 4/28/10 13:41, Jackson, Bruce wrote:
> Hi All
>
> I have Felix embedded into an Android app, and I'm trying to export the
> packages from the Android environment (e.g. android, android.app, etc) into
> Felix.
>
> I have a couple of questions: first, can I still use the pre-4.2
> constructor:
>
> Felix felix = new Felix(Properties props);
>
> ...and if I do so passing in a properties file which contains a
> semicolon-seperated list of packages as per the attached, should I see this
> working properly?
>    

Which version of the framework are you using? Should be fine for 2.0.x 
since it needs a Map and Properties is a Map...however, some of the 
property names have changed since they were standardized in R4.2.

> Felix starts ok, but when I try to deploy any bundles to it (for example a
> dexified org.apache.log4j) I get a message fro the debugger when I call:
>
> BundleContent bc = felix.getBundleContent();
> bc.installBundle(name, inputStream);
>
> 04-28 18:31:45.716: ERROR/SkiftaService(6274): Unresolved constraint in
> bundle org.apache.log4j [1]: package; (package=javax.xml.parsers)
>
> ...which seems to suggest that it can't find the package.
>
> Any ideas?
>    

Not sure off hand. Try Karl's suggestion.

-> richard

> Thanks
>
> Bruce
>
>