users@jersey.java.net

[Jersey] Re: Deserializing nested objects

From: António Mota <amsmota_at_gmail.com>
Date: Wed, 7 Dec 2011 09:31:43 +0000

Hi, thanks for your suggestions taht put me in the rigth path. In the end I
removed the @XmlJavaTypeAdapter and added the @XmlElement with a
type=concrete class. It's not ideal because it makes no sense to have a
interface tied to a concrete class, but will do for now...

This on the server, on the client was a little more complicated because at
some point it was running OK from the AppletViewer but not with the Applet
from the server...


Cheers.

On 25 November 2011 18:15, Tatu Saloranta <tsaloranta_at_gmail.com> wrote:

> 2011/11/25 António Mota <amsmota_at_gmail.com>:
> > Hi, thanks for your response.
> > I tried to test with another method returning a single instance of my
> Image
> > class instead of a List<Image> and the problem still happens, meaning
> it's
>
> Ok, I am guessing you problem is here:
>
> ...
> > @XmlRootElement(name="imageAnnotation")
> > @XmlAccessorType(XmlAccessType.NONE)
> > public class ImageAnnotation {
> > @XmlElement
> > private long id;
> > @XmlElement
> > private int imageId;
> > @XmlElement
> > private String reference;
> > @XmlElement
> > private String comments = null;
> > @XmlElement
> > private int page;
> > @XmlJavaTypeAdapter(AnyTypeAdapter.class)
> > private BoxCoordinates coordinates;
>
> Two guesses:
>
> * Depending on exactly how 'getCoordinates()' is defined, maybe type
> it gives is different from BoxCoordinates -- if it returned Object,
> we'd get this error (but I guess this is not the case)
> * Not sure if you'd need to add @XmlElement next to
> @XmlJavaTypeAdapter, to make this field visible. You can try it to see
> if anything changes.
>
> Also: are you using 1.9.x or earlier version? (apologies if I missed
> this part). 1.9 should work better wrt property introspection than
> earlier versions.
>
> -+ Tatu +-
>