Hi Tyson,
That bug is related to a resource method returning a collection. If i
understand correctly, in your case, it is something to do with a
collection as a JAXB property i.e. your top-level JAXB beans are
getting instantiated but some part of it is not.
Perhaps you can verify the following:
1) Returning an instance of MyObj as XML or JSON. It may be that the
JSON that is generated is not what you expect. In general JAXB
ignores stuff it does not understand so it could be ignoring the JSON
information associated with "collectionValues" because it does not
have the required XML infoset structure i.e. do
@GET
@Produces(<xml and json>)
public MyObj get() {
MyObj o = ....
return o;
}
2) Check that it works with XML.
Also can you send the JAXB beans?
Thanks,
Paul.
On Aug 16, 2008, at 12:16 AM, Tyson Norris wrote:
> Whoops…
> Just noticed this:
> https://jersey.dev.java.net/issues/show_bug.cgi?id=18
>
> I will try out creating a Collection wrapper.
>
> Sorry for the noise…
> Tyson
>
> From: Tyson Norris
> Sent: Friday, August 15, 2008 2:49 PM
> To: 'users_at_jersey.dev.java.net'
> Subject: RE: JAXB/JSON Array reading problem (Array writing is OK)
>
> Some additional info I forgot to mention:
> - version: I’m using 0.8ea version of Jersey
> - my collection elements are getting created properly, and
> the collection is read from the converter (by JAXB unmarshaller)
> but the collection is never assigned to the converter property.
> I will try a similar test with XML data and see what happens…
> Tyson
>
> From: Tyson Norris
> Sent: Friday, August 15, 2008 2:31 PM
> To: 'users_at_jersey.dev.java.net'
> Subject: JAXB/JSON Array reading problem (Array writing is OK)
>
> Hi –
> I am trying to send JSON data into a jersey service using HTTP POST.
>
> This works, in general, for me, except one JAXB property is type
> Collection, and JAXB does not seem to unmarshall the collection;
> the collection value (on the JAXB converter) is always null, and
> the setter is never called.
>
> For example, I am sending something like:
>
> {“myObj”:{“prop1” : “value1”, “prop2” : “value2”,
> “collectionValues” : [{“itemProp1” : itemvalue1”,
> “itemProp2”:”itemValue2”}]}}
>
> My JAXB converter is created properly, and non-collection property
> values are assigned (i.e. I see that getProp1() returns “value1”,
> etc), but: setCollectionValues() is never invoked, and therefore my
> collection values are not available in the JAXB object.
>
> When I use the same JAXB Object to return data in JSON format, the
> collectionValues are properly marshaled to the same JSON format
> listed here.
>
> I have tried changing the type of collection in the
> getCollectionValues/setCollectionValues methods from
> java.util.Collection<ItemPropConverter> to
> java.util.List<ItemPropConverter>, but I get the same results
> (collection is never set when sending data in, data is properly
> translated to JSON when sending data out).
>
> Any ideas what might cause this?
>
> Thanks!
> Tyson
>