简体   繁体   中英

Jackson object mapper exception

I wrote a CGM server. There I used Jackson object mapper.( Not sure I used correct library: jackson-all-1.9) After running following exception occurred.

org.codehaus.jackson.map.JsonMappingException: No serializer found for class Content and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS) )

It says to disable SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS .

 ObjectMapper mapper = new ObjectMapper();
 mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);

Again compile time exception came.

SerializationFeature cannot be resolved to a variable.

How to solve this? I think i have used wrong library.

I had the same problem when I tried to use a good looking GCM server example found at http://hmkcode.com/android-google-cloud-messaging-tutorial/

Apart from changing the keys and IDs, the only thing I had to add to make it work is the following line in front of the " public class... " line:

@JsonAutoDetect(fieldVisibility = Visibility.ANY)

I added this line in the Content.java and the POST2GCM.java file then it was all good to go! working fine!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM