Hi,
I'm trying out the JSON POJO mapping support in Jersey 1.17.
I've done some testing how JSON deserialization behaves when the POJOs
change on the other end.
I get the following error when the server uses a newer version of a
data model with a new property added to an object:
UnrecognizedPropertyException: Unrecognized field "email"
Apparently, Jackson has a feature called "FAIL_ON_UNKNOWN_PROPERTIES"
that allows
disabling this behaviour.
I tried looking at Jersey documentation but couldn't find any info on
how to turn on this feature.
How do I enable it in Jersey?
Here's a stack trace extract:
Exception in thread "main"
com.sun.jersey.api.client.ClientHandlerException:
org.codehaus.jackson.map.exc.UnrecognizedPropertyException:
Unrecognized field "email" (Class com.foo.bar.profile.api.v1.UserJ),
not marked as ignorable
at [Source: java.io.ByteArrayInputStream_at_71a3310a; line: 1, column:
106] (through reference chain:
com.foo.bar.profile.api.v1.UserJ["email"])
at
com.sun.jersey.api.client.ClientResponse.getEntity(ClientResponse.java:
575)
at
com.sun.jersey.api.client.ClientResponse.getEntity(ClientResponse.java:
517)
at
com.sun.jersey.api.client.WebResource.handle(WebResource.java:684)
at
com.sun.jersey.api.client.WebResource.access$200(WebResource.java:74)
at
com.sun.jersey.api.client.WebResource$Builder.get(WebResource.java:507)
at
com.foo.bar.profile.client.ProfileClientJSON.getUserJSONJersey(ProfileC
lientJSON.java:80)
at
com.foo.bar.profile.client.ProfileClientJSON.main(ProfileClientJSON.jav
a:44)
Caused by: org.codehaus.jackson.map.exc.UnrecognizedPropertyException:
Unrecognized field "email" (Class com.foo.bar.profile.api.v1.UserJ),
not marked as ignorable
at [Source: java.io.ByteArrayInputStream_at_71a3310a; line: 1, column:
106] (through reference chain:
com.foo.bar.profile.api.v1.UserJ["email"])
at
org.codehaus.jackson.map.exc.UnrecognizedPropertyException.from(Unrecog
nizedPropertyException.java:53)
at
org.codehaus.jackson.map.deser.StdDeserializationContext.unknownFieldEx
ception(StdDeserializationContext.java:267)
at
org.codehaus.jackson.map.deser.std.StdDeserializer.reportUnknownPropert
y(StdDeserializer.java:649)
at
org.codehaus.jackson.map.deser.std.StdDeserializer.handleUnknownPropert
y(StdDeserializer.java:635)
at
org.codehaus.jackson.map.deser.BeanDeserializer.handleUnknownProperty(B
eanDeserializer.java:1355)
at
org.codehaus.jackson.map.deser.BeanDeserializer.deserializeFromObject(B
eanDeserializer.java:717)
at
org.codehaus.jackson.map.deser.BeanDeserializer.deserialize(BeanDeseria
lizer.java:580)
at
org.codehaus.jackson.map.ObjectMapper._readValue(ObjectMapper.java:2695
)
at
org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:1308)
at
org.codehaus.jackson.jaxrs.JacksonJsonProvider.readFrom(JacksonJsonProv
ider.java:419)
at
com.sun.jersey.json.impl.provider.entity.JacksonProviderProxy.readFrom(
JacksonProviderProxy.java:139)
at
com.sun.jersey.api.client.ClientResponse.getEntity(ClientResponse.java:
565)
... 6 more
marko