I have a package that only includes the xsd file for creating (via JAXB) general classes that are relevant to our server and client applications. Thus, these classes contain XML annotations.
One client is an Android app. I also want to use these classes here to deserialize JSON, because I am communicating with the REST service that supplies JSON (with Jersey / Jackson ).
I am trying to use Jackson (version 1.7.2) on Android:
ObjectMapper mapper = new ObjectMapper();
mapper = mapper.configure(DeserializationConfig.Feature.USE_ANNOTATIONS,
false);
mapper = mapper.configure(SerializationConfig.Feature.USE_ANNOTATIONS,
false);
FooBar someObject = (FooBar) mapper.readValue(jsonString, FooBar.class);
Although I am setting up MAPPER, I should avoid using annotations, but I still get
02-07 09:30:18.631: ERROR/AndroidRuntime(447): java.lang.NoClassDefFoundError: javax.xml.bind.annotation.XmlAccessorType
02-07 09:30:18.631: ERROR/AndroidRuntime(447): at java.lang.Class.getDeclaredAnnotations(Native Method)
02-07 09:30:18.631: ERROR/AndroidRuntime(447): at org.codehaus.jackson.map.introspect.AnnotatedClass.resolveClassAnnotations(AnnotatedClass.java:292)
02-07 09:30:18.631: ERROR/AndroidRuntime(447): at org.codehaus.jackson.map.introspect.AnnotatedClass.construct(AnnotatedClass.java:139)
Who knows the trick to stop Jackson from resolving annotations.
Thanks Klaus
source