Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jackson on Android: NoClassDefFoundError ObjectMapper error

I've tried to implement Robospice into my application according the Robospice's Starter Guide. I'm getting the following errors:

09-11 20:28:32.290: E/AndroidRuntime(25480): FATAL EXCEPTION: main

09-11 20:28:32.290: E/AndroidRuntime(25480): java.lang.NoClassDefFoundError: org.codehaus.jackson.map.ObjectMapper

09-11 20:28:32.290: E/AndroidRuntime(25480): at org.springframework.http.converter.json.MappingJacksonHttpMessageConverter.(MappingJacksonHttpMessageConverter.java:54)

09-11 20:28:32.290: E/AndroidRuntime(25480): at com.my.app.io.service.JsonSpiceService.createRestTemplate(JsonSpiceService.java:37)

Here is what I've tried so far:

  • I have the following jars included (libs folder): jackson-annotations-2.2.2.jar, jackson-core-2.2.2.jar, jackson-databind-2.2.2.jar (among all the other Robospice-related jars but Jackson is the one causing problems). I've also tested it with 2.2.3 (same problem)
  • All of them are checked under 'Order and Export' in Eclipse (as well as all of the other Robospice-related jars)
  • I'm not using Maven
  • I've tried deleting and adding new jars, cleaning the project - none of these worked
  • My app is targeted at API level 17 (Google APIs, 4.2.2)

What else could cause this problem?

like image 892
syntagma Avatar asked Jul 05 '26 22:07

syntagma


1 Answers

You are referencing org.codehaus.jackson.map.ObjectMapper when you should be referencing com.fasterxml.jackson.databind.ObjectMapper which is in jackson-databind.

This is probably because MappingJacksonHttpMessageConverter uses the old version, which is in jackson-mapper-asl-1.9.xx. You can get those here.

Otherwise, use MappingJackson2HttpMessageConverter (note the 2) which correctly uses the newest version of jackson.

like image 103
Sotirios Delimanolis Avatar answered Jul 07 '26 11:07

Sotirios Delimanolis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!