users@jersey.java.net

Re: [Jersey] Re: java.lang.NullPointerException on Android

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Mon, 12 Apr 2010 11:06:49 +0200

On Apr 9, 2010, at 8:39 PM, Lucas Ventura wrote:

>
> Hi!
> I'm also trying to use Jersey on Android.
> I've used the 1.1.5.1 version of the lib, but I receive the same
> error.
>
> About your last question
>
> Paul Sandoz wrote:
>>
>>
>> On Dec 29, 2009, at 8:01 PM, Николай Панфилов wrote:
>>
>> Does Android require you to compile the Jersey source into something
>> other than Java byte code and package it up a little differently?
>>
> Yes, it does. It recompiles the .class files into .dex files (Dalvik
> Virtual
> Machine specific bytecode).
> Is there any problem?

Not sure. It may be that you just need to package up the META-INF/
services files.

> What it is supposed to do with the META-INF/services files?
>

Are you including those files in the android equivalent of a jar file?

Also if you are merging say jersey-core, jersey-server etc together
you may need to merge the contents of any META-INF/services of the
same name.

Jersey requires those files because they declare components for Jersey
to function. Those files are really just a convention to define
implementations of specific interfaces, the implementations of which
Jersey requires to function correctly. Jersey attempts to class load
those files.

Paul.