Tatu,
using the JacksonJaxbJsonProvider does help for this particular case, but
this causes issues where I have the beans annotated with JAXB having the
accessor type set as FIELD, meaning few of the properties in the bean could
be optional. While unmarshalling JSON complains about these optional
properties being not set as ignorable.
Probably, the following exception stack trace can shed more light on the
issue that I'm trying to explain:
com.sun.jersey.api.client.ClientHandlerException:
org.codehaus.jackson.map.exc.UnrecognizedPropertyException: Unrecognized
field "lastModifiedDate" (Class
com.infa.cep.yosemite.rest.impl.jaxb.beans.Topic), not marked as ignorable
[java] at [Source: java.io.ByteArrayInputStream_at_770440dd; line: 1,
column: 635] (through reference chain:
com.infa.cep.yosemite.rest.impl.jaxb.beans.Topic["lastModifiedDate"])
[java] at
org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:194)
[java] at org.apache.tools.ant.taskdefs.Java.run(Java.java:771)
[java] at
org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:221)
[java] at
org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:135)
[java] at org.apache.tools.ant.taskdefs.Java.execute(Java.java:108)
[java] at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
[java] at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown
Source)
[java] at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[java] at java.lang.reflect.Method.invoke(Method.java:601)
[java] at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
[java] at org.apache.tools.ant.Task.perform(Task.java:348)
[java] at org.apache.tools.ant.Target.execute(Target.java:392)
[java] at org.apache.tools.ant.Target.performTasks(Target.java:413)
[java] at
org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
[java] at
org.apache.tools.ant.Project.executeTarget(Project.java:1368)
[java] at
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
[java] at
org.apache.tools.ant.Project.executeTargets(Project.java:1251)
[java] at org.apache.tools.ant.Main.runBuild(Main.java:811)
[java] at org.apache.tools.ant.Main.startAnt(Main.java:217)
[java] at
org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
[java] at
org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
[java] Caused by: com.sun.jersey.api.client.ClientHandlerException:
org.codehaus.jackson.map.exc.UnrecognizedPropertyException: Unrecognized
field "lastModifiedDate" (Class
com.infa.cep.yosemite.rest.impl.jaxb.beans.Topic), not marked as ignorable
[java] at [Source: java.io.ByteArrayInputStream_at_770440dd; line: 1,
column: 635] (through reference chain:
com.infa.cep.yosemite.rest.impl.jaxb.beans.Topic["lastModifiedDate"])
[java] at
com.sun.jersey.api.client.ClientResponse.getEntity(ClientResponse.java:575)
[java] at
com.sun.jersey.api.client.ClientResponse.getEntity(ClientResponse.java:517)
Thanks,
Naresh
On Mon, Nov 19, 2012 at 11:52 PM, Tatu Saloranta <tsaloranta_at_gmail.com>wrote:
> On Sun, Nov 18, 2012 at 9:09 PM, Srinivas Naresh Bhimisetty
> <shri.naresh_at_gmail.com> wrote:
> > Thanks Tatu.
> > Unfortunately, I wouldn't be able to use the POJO mapping, since I use a
> lot
> > of JAXB annotated beans, and Jackson doesn't understand these
> annotations,
> > gives some errors at runtime.
>
> Jackson understands JAXB annotations with JAXB annotation module. But
> if you use the standard Bean naming convention, most of those are not
> needed: JAXB implementations need much more information because XML
> has higher impedance to POJOs than JSON does.
>
> What errors are you specifically getting?
>
> -+ Tatu +-
>