felix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jackson, Bruce" <bru...@qualcomm.com>
Subject Re: Felix on Android
Date Tue, 16 Feb 2010 10:12:01 GMT
I think there's more to this than me being a bit thick :-)

I now have the same environment on both my mac and Nexus, namely:

(on the mac)

-> ps
START LEVEL 1
   ID   State         Level  Name
[   0] [Active     ] [    0] System Bundle (2.0.3)
[   1] [Active     ] [    1] Apache Felix Bundle Repository (1.4.3)
[   2] [Active     ] [    1] Apache Felix Shell Service (1.4.2)
[   3] [Active     ] [    1] Apache Felix Shell TUI (1.4.1)
[   4] [Active     ] [    1] Httptest (1.0.0.201002151713)
[   5] [Active     ] [    1] Servlet API Bundle (2.5.0.v200806031605)
[   6] [Active     ] [    1] HTTP Service (0.8.0.SNAPSHOT)

and (on the Nexus)

-> ps
START LEVEL 1
   ID   State         Level  Name
[   0] [Active     ] [    0] System Bundle (2.0.3)
[   1] [Active     ] [    1] Apache Felix Shell Service (1.0.2)
[   2] [Active     ] [    1] Apache Felix Shell TUI (1.0.2)
[   4] [Active     ] [    1] Apache Felix Log Service (1.0.0)
[   5] [Active     ] [    1] Apache Felix Configuration Admin Service (1.2.4)
[   9] [Active     ] [    1] Servlet API Bundle (2.5.0.v200806031605)
[  10] [Active     ] [    1] HTTP Service (0.8.0.SNAPSHOT)
[  13] [Resolved   ] [    1] Httptest (1.0.0.201002151713)

Now, you’ll see from the above that on the Nexus, my very simple HTTP test bundle (it just
registers a servlet context at /test and prints Hello World!) is resolved and not active.
If I try to start it, I get the following:

-> start 13
Feb 16, 2010 10:09:56 AM java.io.BufferedWriter <init>
INFO: Default buffer size used in BufferedWriter constructor. It would be better to be explicit
if an 8k-char buffer is required.
org.osgi.framework.BundleException: Activator start error in bundle com.skifta.httptest [13].
    at org.apache.felix.framework.Felix.activateBundle(Felix.java:1803)
    at org.apache.felix.framework.Felix.startBundle(Felix.java:1678)
    at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:905)
    at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:892)
    at org.apache.felix.shell.impl.StartCommandImpl.execute(StartCommandImpl.java:82)
    at org.apache.felix.shell.impl.Activator$ShellServiceImpl.executeCommand(Activator.java:276)
    at org.apache.felix.shell.tui.Activator$ShellTuiRunnable.run(Activator.java:167)
    at java.lang.Thread.run(Thread.java:1096)
Caused by: java.lang.NoClassDefFoundError: org.mortbay.jetty.servlet.ServletHandler$Context
    at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:109)
    at org.mortbay.http.HttpContext.addHandler(HttpContext.java:465)
    at org.mortbay.http.HttpContext.addHandler(HttpContext.java:476)
    at org.apache.felix.http.jetty.HttpServiceImpl$ServletContextGroup.init(HttpServiceImpl.java:318)
    at org.apache.felix.http.jetty.HttpServiceImpl$ServletContextGroup.<init>(HttpServiceImpl.java:301)
    at org.apache.felix.http.jetty.HttpServiceImpl$ServletContextGroup.<init>(HttpServiceImpl.java:291)
    at org.apache.felix.http.jetty.HttpServiceImpl.registerServlet(HttpServiceImpl.java:128)
    at com.skifta.httptest.Activator.start(Activator.java:21)
    at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:661)
    at org.apache.felix.framework.Felix.activateBundle(Felix.java:1756)
    ... 7 more
Caused by: java.lang.UnsupportedOperationException: can't load this type of class file
    at java.lang.VMClassLoader.defineClass(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:338)
    at org.apache.felix.framework.ModuleImpl$ModuleClassLoader.findClass(ModuleImpl.java:1837)
    at org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:723)
    at org.apache.felix.framework.ModuleImpl.access$100(ModuleImpl.java:61)
    at org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1698)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
    ... 17 more
java.lang.NoClassDefFoundError: org.mortbay.jetty.servlet.ServletHandler$Context

Several things. First, the behavoiur is not the some on the mac and Nexus, even though the
framework and bundles are. Second, the class org.mortbay.jetty.servlet.ServletHandler$Context
is in the Jetty bundle , it just can’t be resolved on Android.

Any ideas?


On 15/02/2010 18:14, "Clement Escoffier" <clement.escoffier@gmail.com> wrote:

> As said by Marcel, you need to also deploy the OSGi compendium
> On Android, I use:
> http://repo2.maven.org/maven2/org/apache/felix/org.osgi.compendium/1.4.0/org.o
> sgi.compendium-1.4.0.jar
>
>
> Clement
>
> On 15.02.2010, at 16:52, Jackson, Bruce wrote:
>
>> What other bundles do you have installed when running this?
>> I've added the following:
>>
>> -> ps
>> START LEVEL 1
>>   ID   State         Level  Name
>> [   0] [Active     ] [    0] System Bundle (2.0.3)
>> [   1] [Active     ] [    1] Apache Felix Shell Service (1.0.2)
>> [   2] [Active     ] [    1] Apache Felix Shell TUI (1.0.2)
>> [   4] [Active     ] [    1] Apache Felix Log Service (1.0.0)
>> [   5] [Active     ] [    1] Apache Felix Configuration Admin Service (1.2.4)
>> [   7] [Installed  ] [    1] HTTP Service (1.0.0)
>> [   9] [Active     ] [    1] Servlet API Bundle (2.5.0.v200806031605)
>>
>> but I still find that the HTTP service 1.0 complains that:
>>
>> org.osgi.framework.BundleException: Unresolved constraint in bundle
>> org.apache.felix.http.jetty [7]: package;
>> (&(package=org.osgi.service.http)(version>=1.2.0))
>>
>> when I start the http service?
>>
>> On 15/02/2010 13:14, "Clement Escoffier" <clement.escoffier@gmail.com> wrote:
>>
>>>
>>> On 15.02.2010, at 13:31, Jackson, Bruce wrote:
>>>
>>>> Clement, when you say 'I use the HTTP Service 1.0.0. Could you try with
>>>> that
>>>> one ?' which one do you mean?
>>>
>>> I use a older version of the HTTP service implementation (the version 1.0.0
>>> which use an older version of Jetty).
>>> http://archive.apache.org/dist/felix/org.apache.felix.http.jetty-1.0.0-proje
>>> ct
>>> .zip
>>> http://archive.apache.org/dist/felix/org.apache.felix.http.jetty-1.0.0.jar
>>>
>>> Try with this bundle. But for sure, use on of the latest Felix framework. We
>>> did a couple of fixes to support android correctly.
>>>
>>> Regards,
>>>
>>> Clement
>>>
>>>
>>>
>>>
>>>>
>>>> Thanks
>>>> Bruce
>>>>
>>>>
>>>> On 12/02/2010 18:57, "Clement Escoffier" <clement.escoffier@gmail.com>
>>>> wrote:
>>>>
>>>>>
>>>>> On 12.02.2010, at 17:27, Jackson, Bruce wrote:
>>>>>
>>>>>> I've got the Felix framework installed on my Nexus. If I download
the
>>>>>> org.apache.felix.http.jetty-2.0.4.jar bundle from the Felix site,
dx it
>>>>>> (which generates piles of warnings) push it to the phone, start Felix
and
>>>>>> then install the jetty bundle, Felix just hangs:
>>>>>>
>>>>>> -> ps
>>>>>> START LEVEL 1
>>>>>> ID   State         Level  Name
>>>>>> [   0] [Active     ] [    0] System Bundle (1.4.0)
>>>>>> [   1] [Active     ] [    1] Apache Felix Shell Service (1.0.2)
>>>>>> [   2] [Active     ] [    1] Apache Felix Shell TUI (1.0.2)
>>>>>> [   3] [Active     ] [    1] JDOM (1.0.0.v200803070505)
>>>>>> -> install file:bundle/org.apache.felix.http.jetty-2.0.4.jar
>>>>>> Feb 12, 2010 4:15:03 PM java.io.BufferedWriter <init>
>>>>>> INFO: Default buffer size used in BufferedWriter constructor. It
would be
>>>>>> better to be explicit if an 8k-char buffer is required.
>>>>>> Feb 12, 2010 4:15:03 PM java.io.BufferedWriter <init>
>>>>>> INFO: Default buffer size used in BufferedWriter constructor. It
would be
>>>>>> better to be explicit if an 8k-char buffer is required.
>>>>>> Feb 12, 2010 4:15:03 PM java.io.BufferedWriter <init>
>>>>>> INFO: Default buffer size used in BufferedWriter constructor. It
would be
>>>>>> better to be explicit if an 8k-char buffer is required.
>>>>>> Feb 12, 2010 4:15:04 PM java.io.BufferedWriter <init>
>>>>>> INFO: Default buffer size used in BufferedWriter constructor. It
would be
>>>>>> better to be explicit if an 8k-char buffer is required.
>>>>>> Feb 12, 2010 4:15:04 PM java.io.BufferedWriter <init>
>>>>>> INFO: Default buffer size used in BufferedWriter constructor. It
would be
>>>>>> better to be explicit if an 8k-char buffer is required.
>>>>>> Feb 12, 2010 4:15:04 PM java.io.BufferedWriter <init>
>>>>>> INFO: Default buffer size used in BufferedWriter constructor. It
would be
>>>>>> better to be explicit if an 8k-char buffer is required.
>>>>>> Bundle ID: 5
>>>>>> -> ps
>>>>>> START LEVEL 1
>>>>>> ID   State         Level  Name
>>>>>> [   0] [Active     ] [    0] System Bundle (1.4.0)
>>>>>> [   1] [Active     ] [    1] Apache Felix Shell Service (1.0.2)
>>>>>> [   2] [Active     ] [    1] Apache Felix Shell TUI (1.0.2)
>>>>>> [   3] [Active     ] [    1] JDOM (1.0.0.v200803070505)
>>>>>> [   5] [Installed  ] [    1] Apache Felix Http Jetty (2.0.4)
>>>>>> -> start 5
>>>>>> Feb 12, 2010 4:15:08 PM java.io.BufferedWriter <init>
>>>>>> INFO: Default buffer size used in BufferedWriter constructor. It
would be
>>>>>> better to be explicit if an 8k-char buffer is required.
>>>>>> DEBUG: WIRE: 5.0 -> javax.xml.parsers -> 0
>>>>>> DEBUG: WIRE: 5.0 -> org.xml.sax -> 0
>>>>>> DEBUG: WIRE: 5.0 -> javax.servlet.resources -> 5.0
>>>>>> DEBUG: WIRE: 5.0 -> javax.servlet -> 5.0
>>>>>> DEBUG: WIRE: 5.0 -> javax.security.cert -> 0
>>>>>> DEBUG: WIRE: 5.0 -> org.osgi.util.tracker -> 0
>>>>>> DEBUG: WIRE: 5.0 -> org.osgi.framework -> 0
>>>>>> DEBUG: WIRE: 5.0 -> javax.servlet.jsp.resources -> 5.0
>>>>>> DEBUG: WIRE: 5.0 -> javax.net.ssl -> 0
>>>>>> DEBUG: WIRE: 5.0 -> org.xml.sax.helpers -> 0
>>>>>> DEBUG: WIRE: 5.0 -> org.osgi.service.http -> 5.0
>>>>>> DEBUG: WIRE: 5.0 -> org.apache.felix.http.api -> 5.0
>>>>>> DEBUG: WIRE: 5.0 -> javax.servlet.http -> 5.0
>>>>>>
>>>>>> At this point, I have to CTRL-C to kill Felix. The same thing happened
>>>>>> before
>>>>>> I compiled JDOM with 1.5+. I might be missing something, but my
>>>>>> assumption,
>>>>>> perhaps wrong, was that it was the compiler version that was causing
this
>>>>>> behavior?
>>>>>
>>>>> Hum interesting,
>>>>>
>>>>> Potentially this is very slow, or there is an issue with the NIO.
>>>>> I use the HTTP Service 1.0.0. Could you try with that one ?
>>>>>
>>>>>
>>>>> Clement
>>>>>
>>>>>>
>>>>>> Thanks
>>>>>>
>>>>>> Bruce
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> On 12/02/2010 15:51, "Clement Escoffier" <clement.escoffier@gmail.com>
>>>>>> wrote:
>>>>>>
>>>>>>>
>>>>>>> On 12.02.2010, at 16:45, Jackson, Bruce wrote:
>>>>>>>
>>>>>>>> Whenever you dx a bundle which has been built with a pre-1.5
compiler
>>>>>>>> you
>>>>>>>> will usually get a pile of:
>>>>>>>>
>>>>>>>> warning: Ignoring InnerClasses attribute for an anonymous
inner class
>>>>>>>> that
>>>>>>>> doesn't come with an associated EnclosingMethod attribute.
(This class
>>>>>>>> was
>>>>>>>> probably produced by a broken compiler.)
>>>>>>>>
>>>>>>>> ...messages (assuming that you do use inner classes in the
bundle).
>>>>>>>> These
>>>>>>>> are generated because the bundle was compiled with a pre-1.5
compiler.
>>>>>>>> With
>>>>>>>> something like the org.jdom bundle, the bundle will not work
correctly
>>>>>>>> if
>>>>>>>> it
>>>>>>>> was compiled with a pre-1.5 compiler and then dx-ed, while
using a
>>>>>>>> post-1.5
>>>>>>>> it does.
>>>>>>>>
>>>>>>>> It may a be a broad assessment of the situation, but I took
this
>>>>>>>> experience
>>>>>>>> to indicate that it was required to build bundles with a
post-1.5
>>>>>>>> compiler.
>>>>>>>> Indeed if you look around the web, you'll see this warning
mentioned in
>>>>>>>> relation to a number of problems people are having with getting
apps
>>>>>>>> running
>>>>>>>> on Android, when using JARs that were compiled pre-1.5.
>>>>>>>
>>>>>>> Well, you got less messages if you compile with 1.5+, but that's
does
>>>>>>> say
>>>>>>> that
>>>>>>> a bundle will not work.
>>>>>>> When dexifying iPOJO, I have a couple of message too, but the
complete
>>>>>>> iPOJO
>>>>>>> test suite works on Android (except some features using on the
fly
>>>>>>> bytecode
>>>>>>> generation).
>>>>>>>
>>>>>>> Regards,
>>>>>>>
>>>>>>> Clement
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>>
>>>>>>>> Thanks
>>>>>>>>
>>>>>>>> Bruce
>>>>>>>>
>>>>>>>> On 12/02/2010 15:25, "Karl Pauls" <karlpauls@gmail.com>
wrote:
>>>>>>>>
>>>>>>>>> On Fri, Feb 12, 2010 at 4:22 PM, Jackson, Bruce <brucej@qualcomm.com>
>>>>>>>>> wrote:
>>>>>>>>>> I'm taking here about the ad-on bundles (like http,
for example)
>>>>>>>>>> rather
>>>>>>>>>> than
>>>>>>>>>> the framework. The dx tool needs to have classes
that were compiled
>>>>>>>>>> with
>>>>>>>>>> a
>>>>>>>>>> "new" compiler (i.e. greater than 1.5).
>>>>>>>>>
>>>>>>>>> Since when? Always worked for me. Again, the framework
itself is
>>>>>>>>> compiled for 1.3...
>>>>>>>>>
>>>>>>>>> regards,
>>>>>>>>>
>>>>>>>>> Karl
>>>>>>>>>
>>>>>>>>>> Thanks
>>>>>>>>>>
>>>>>>>>>> Bruce
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> On 12/02/2010 13:33, "Karl Pauls" <karlpauls@gmail.com>
wrote:
>>>>>>>>>>
>>>>>>>>>>> Why would you need 1.5 to be able to dex the
bundle (the framework
>>>>>>>>>>> itself is build for 1.3 btw.)?
>>>>>>>>>>>
>>>>>>>>>>> regards,
>>>>>>>>>>>
>>>>>>>>>>> Karl
>>>>>>>>>>>
>>>>>>>>>>> On Fri, Feb 12, 2010 at 1:15 PM, Jackson, Bruce
>>>>>>>>>>> <brucej@qualcomm.com>
>>>>>>>>>>> wrote:
>>>>>>>>>>>> Hi Pablo
>>>>>>>>>>>>
>>>>>>>>>>>> See the attached code. The biggest problem
I've encountered is that
>>>>>>>>>>>> the
>>>>>>>>>>>> Felix distribution is a huge pain to build
under JDK 1.5, and
>>>>>>>>>>>> therefore
>>>>>>>>>>>> to
>>>>>>>>>>>> be able to use some of the bundles (for example
the http service)
>>>>>>>>>>>> that
>>>>>>>>>>>> are
>>>>>>>>>>>> part of the distribution. Its not a simple
job of just changing a
>>>>>>>>>>>> couple
>>>>>>>>>>>> of
>>>>>>>>>>>> entries in POM files: some components download
pre-built JAR files
>>>>>>>>>>>> from
>>>>>>>>>>>> the
>>>>>>>>>>>> web and explode these, thereby having classes
built under 1.4 which
>>>>>>>>>>>> will
>>>>>>>>>>>> not
>>>>>>>>>>>> work when you dexify the bundles.
>>>>>>>>>>>>
>>>>>>>>>>>> This is something that would be great to
see some work done on by
>>>>>>>>>>>> the
>>>>>>>>>>>> Felix
>>>>>>>>>>>> community, because while its true that the
basic Felix core does
>>>>>>>>>>>> and
>>>>>>>>>>>> will
>>>>>>>>>>>> support Android, most of the add-on bundles
wont.
>>>>>>>>>>>>
>>>>>>>>>>>> For my part, the ideal solution would be
to see the whole framework
>>>>>>>>>>>> be
>>>>>>>>>>>> based
>>>>>>>>>>>> on JDK 1.5 and not 1.4.
>>>>>>>>>>>>
>>>>>>>>>>>> Thanks
>>>>>>>>>>>>
>>>>>>>>>>>> Bruce
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> On 12/02/2010 11:32, "pablomj" <pablomj85@hotmail.es>
wrote:
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> Hi Bruce, I am trying the same, but I don't
have the solution yet.
>>>>>>>>>>>> Do you have some advance?
>>>>>>>>>>>> Salutations, thanks.
>>>>>>>>>>>> Pablo.
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> Jackson, Bruce wrote:
>>>>>>>>>>>>
>>>>>>>>>>>> The Felix site has a useful section on getting
things going on
>>>>>>>>>>>> Android >>>>>>>>
(
>>>>>>>>>>>> http://felix.apache.org/site/apache-felix-and-google-android.html)
>>>>>>>>>>>> but
>>>>>>>>>>>> isn't
>>>>>>>>>>>> so clear about embedding the framework into
an Android app"
>>>>>>>>>>>>
>>>>>>>>>>>> "Apache Felix can also be integrated with
an Android application.
>>>>>>>>>>>> To
>>>>>>>>>>>> achieve
>>>>>>>>>>>> this, you need to embed Felix into onCreate()
method of your
>>>>>>>>>>>> Activity
>>>>>>>>>>>> class
>>>>>>>>>>>> (see Android docs for more details on how
to use an Activity) and
>>>>>>>>>>>> process
>>>>>>>>>>>> your bundles as shown above."
>>>>>>>>>>>>
>>>>>>>>>>>> Has anyone got an example of how you do this?
I understand how to
>>>>>>>>>>>> write
>>>>>>>>>>>> the
>>>>>>>>>>>> Android app, and I get the point being made
here. What I need to
>>>>>>>>>>>> understand
>>>>>>>>>>>> is:
>>>>>>>>>>>>
>>>>>>>>>>>> 1. How do you launch the Felix framework.
What do I need to
>>>>>>>>>>>> instantiate?
>>>>>>>>>>>> 2. Where does the framework get its boot
configuration (i.e. what
>>>>>>>>>>>> bundles
>>>>>>>>>>>> to
>>>>>>>>>>>> load, run levels, environment variables,
etc) from in this case?
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>
>>>>
>>>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message