users@jersey.java.net

[Jersey] Jersey 2.3.1 on Android, why not?

From: Marko Mati? <cipiripper_at_gmail.com>
Date: Mon, 21 Oct 2013 00:05:43 +0200

Hi all.

I am trying to make Jersey 2.3.1 work on Android, but with some "success".
I managed to repack Jersey 2.3.1 and all its dependencies, plus some more
Javax APIs missing on Android using JarJar, it can be compiled now to APK,
executed on DalvikVM - but still not working completely...

I can make it send (post/put) requests and receive responses that are both
of String.class - I can't use the POJO way of using Jersey - meaning if I
execute this: webTarget.request("*").get().readEntity(Companies.class) I
get this: http://pastebin.com/Q8FhnEKW - (see line 51) - even though MIME
type of data returned is "***+json" Jersey can't recognize it.

But if I execute this (with String.class):
webTarget.request("*").get().readEntity(String.class) I get the string
response, but with many warnings like: "Unable to match class for part:
'Ljava/awt/image/RenderedImage;'" (full log here:
http://pastebin.com/Sq2DL2ty).

For now I fixed this to always get String.class and then use Jackson
ObjectMapper to deserialize that stringified JSON to POJO of the given
class, and this works... slow.


So, my questions are:

1. Why can it be (if you look at my full error log) that JSON string is not
deserialized to POJO? Am I missing some configuration between Jackson and
Jersey (I use the latest versions of both)?
2. Is there some hidden Android Jersey version available that works out of
the box? :)
3. Can I turn off
org.glassfish.jersey.message.internal.RenderedImageProvider from code,
without any compiling, repackaging...? Because I see that it is giving me
problems because it wants to use RenderedImage class from AWT which is
pointless on Android... and this slows down my requests.


Thanks in advance!
Marko