users@jersey.java.net

[Jersey] Re: Jersey hangs when invalid JSON is sent in POST request

From: Setanta Mathews <setanta.mathews_at_gmail.com>
Date: Wed, 30 Mar 2011 17:50:10 +0100

Hi,

The problems were to do with polymorphism.

Scenario:

* I had two classes, Foo and Bar where Bar extends Foo.
* I created a list of type List<Foo> and put an instance of Foo and an
instance of Bar in it.
* I was ending up with JSON that was being unmarshalled to a list that had
two Foos in it, instead of a Foo and a Bar.

Now, this was happening for me with Jersey 1.4, which used Jackson 1.5 (I
think). It mightn't be a problem with the newer releases.

Cheers,

Setanta






On Wed, Mar 30, 2011 at 5:43 PM, Tatu Saloranta <tsaloranta_at_gmail.com>wrote:

> On Wed, Mar 30, 2011 at 1:28 AM, setanta.mathews_at_gmail.com
> <setanta.mathews_at_gmail.com> wrote:
> > Hi,
> >
> >
> >
> >> To fully switch to JSON Jackson support, which would
> >> work also for a non-JAXB classes, and with simplified
> >> configuration, you may want to set the JSON POJO mapping
> >> feature as described at [1]. No JAXBContext resolver
> >> would be then needed.
> >>
> >
> > I tried this approach but found that while it was very easy to marshal
> > objects to JSON, frequently this JSON could not be unmarshalled back
> into
> > the objects. Of course, a solution would be to fix this with jackson
>
> This sounds odd, except for wrapping case. I never quite understood
> why wrapping was needed (except for compatibility purposes), so while
> it is added on serialization, there is no counterpart for
> deserialization (one could be added, of course, if users wanted it).
>
> But it sounds like you have some other issue? If so, please let us
> know at Jackson project,
>
> -+ Tatu +-
>