users@jersey.java.net

[Jersey] Re: jackson json mapping issue

From: suchitha koneru <suchi.koneru_at_gmail.com>
Date: Thu, 28 Jun 2012 10:16:35 -0700

Thanks Tatu for the response. I have inner classes , can this be a issue
for derserialization as stated in the
JIRA http://jira.codehaus.org/browse/JACKSON-594.

The class Retailer and its Data member RetailerCountries both have a
static inner class of same name" Supported Currencies" but with different
definitions.

can this be a problem ?



On Wed, Jun 27, 2012 at 10:18 AM, Tatu Saloranta <tsaloranta_at_gmail.com>wrote:

> I don't know what the issue is, but I do not think the Jira issue you
> reference is related, as I don't see any generic type declarations.
> The underlying issue is exactly what error message says: a POJO is
> typically serialized out of JSON Object, but what JSON has is an
> array. You may want to check out what kind of JSON is being given to
> deserializer, and see why it does not match. One possibility is
> addition of JSON type information.
>
> -+ Tatu +-
>
> On Wed, Jun 27, 2012 at 9:58 AM, suchitha koneru <suchi.koneru_at_gmail.com>
> wrote:
> > Not sure if the mail was sent to the user group the first time as I did
> not
> > see it in my inbox.
> >
> >
> > On Tue, Jun 26, 2012 at 11:12 AM, suchitha koneru <
> suchi.koneru_at_gmail.com>
> > wrote:
> >>
> >> Hello Jersey Users,
> >> We are using jersey-server, jersery -client and jersey-json jars
> >> of version 1.11 in our application which runs on a jetty server. I
> get
> >> the following exception when json is being deserialized into Retailer
> pojo
> >> (the pojo is attached and it is generated by using xjc compiler from
> >> Retailer XSD). Both Retailer and Retailer countrty pojos have a inner
> >> class Supported Currencies with different definition. I think this is
> >> causing the issue.
> >>
> >>
> >> Caused by: org.codehaus.jackson.map.JsonMappingException: Can not
> >> deserialize instance of
> >> com.bn.cloud.pm.data.vo.catalog.retl.Retailer$SupportedCurrencies out of
> >> START_ARRAY token
> >> at [Source: java.io.ByteArrayInputStream_at_3bdd6a67; line: 1, column:
> 101]
> >> (through reference chain:
> >> com.bn.cloud.pm.data.vo.catalog.retl.Retailer["supportedCurrencies"])
> >> at
> >>
> org.codehaus.jackson.map.JsonMappingException.from(JsonMappingException.java:163)
> >> ~[jackson-mapper-asl-1.9.2.jar:1.9.2]
> >> at
> >>
> org.codehaus.jackson.map.deser.StdDeserializationContext.mappingException(StdDeserializationContext.java:219)
> >> ~[jackson-mapper-asl-1.9.2.jar:1.9.2]
> >> at
> >>
> org.codehaus.jackson.map.deser.StdDeserializationContext.mappingException(StdDeserializationContext.java:212)
> >> ~[jackson-mapper-asl-1.9.2.jar:1.9.2]
> >> at
> >>
> org.codehaus.jackson.map.deser.BeanDeserializer.deserializeFromArray(BeanDeserializer.java:869)
> >> ~[jackson-mapper-asl-1.9.2.jar:1.9.2]
> >> at
> >>
> org.codehaus.jackson.map.deser.BeanDeserializer.deserialize(BeanDeserializer.java:597)
> >> ~[jackson-mapper-asl-1.9.2.jar:1.9.2]
> >> at
> >>
> org.codehaus.jackson.map.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:299)
> >> ~[jackson-mapper-asl-1.9.2.jar:1.9.2]
> >> at
> >>
> org.codehaus.jackson.map.deser.SettableBeanProperty$FieldProperty.deserializeAndSet(SettableBeanProperty.java:579)
> >> ~[jackson-mapper-asl-1.9.2.jar:1.9.2]
> >> at
> >>
> org.codehaus.jackson.map.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:697)
> >> ~[jackson-mapper-asl-1.9.2.jar:1.9.2]
> >> at
> >>
> org.codehaus.jackson.map.deser.BeanDeserializer.deserialize(BeanDeserializer.java:580)
> >> ~[jackson-mapper-asl-1.9.2.jar:1.9.2]
> >> at
> >> org.codehaus.jackson.map.ObjectMapper._readValue(ObjectMapper.java:2695)
> >> ~[jackson-mapper-asl-1.9.2.jar:1.9.2]
> >> at
> org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:1308)
> >> ~[jackson-mapper-asl-1.9.2.jar:1.9.2]
> >> at
> >>
> org.codehaus.jackson.jaxrs.JacksonJsonProvider.readFrom(JacksonJsonProvider.java:419)
> >> ~[jackson-jaxrs-1.9.2.jar:1.9.2]
> >> at
> >>
> com.sun.jersey.json.impl.provider.entity.JacksonProviderProxy.readFrom(JacksonProviderProxy.java:139)
> >> ~[jersey-json-1.11.jar:1.11]
> >> at
> >>
> com.sun.jersey.api.client.ClientResponse.getEntity(ClientResponse.java:554)
> >> ~[jersey-client-1.11.jar:1.11]
> >>
> >> I suspect the issue is
> >>
> >> http://jira.codehaus.org/browse/JACKSON-743
> >>
> >>
> >> I am not aware of any work arounds. Could you please suggest what can be
> >> done to solve this issue ?
> >>
> >>
> >> Thank you,
> >> Suchitha
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >
> >
>