salilbc / rest-assured

Automatically exported from code.google.com/p/rest-assured
0 stars 0 forks source link

move to new Jackson 2.0 #189

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Using rest-assured 1.6.2, if the classpath contains the new Jackson library 
(2.0) instead of the old one (1.x), rest-assured fails with: 

java.lang.IllegalStateException: Cannot serialize object because no JSON 
serializer found in classpath. Please put either Jackson or Gson in the 
classpath.

This is because the new Jackson library isn't backwards compatible with the old 
one (https://github.com/FasterXML/jackson-core). 
Spring for example solves this with: 
final ClassLoader classLoader = getClass().getClassLoader();
if (ClassUtils.isPresent("com.fasterxml.jackson.databind.ObjectMapper", 
classLoader)) {
    messageConverters.add(new MappingJackson2HttpMessageConverter());
} else if (ClassUtils.isPresent("org.codehaus.jackson.map.ObjectMapper", 
classLoader)) {
    messageConverters.add(new MappingJacksonHttpMessageConverter());
}

A similar solution should be included in rest-assured as well, so that it knows 
how to use Jackson 2.0, instead of just 1.x. 
Thanks. 

Original issue reported on code.google.com by hanrisel...@gmail.com on 16 Aug 2012 at 3:48

GoogleCodeExporter commented 9 years ago
You're absolutely right! Thanks for sharing and for the suggested solution.

Original comment by johan.ha...@gmail.com on 17 Aug 2012 at 5:43

GoogleCodeExporter commented 9 years ago

Original comment by johan.ha...@gmail.com on 17 Aug 2012 at 6:17

GoogleCodeExporter commented 9 years ago
I've now fixed this is in trunk. Please help out by verifiying that it works. 
You can either build it yourself from trunk or depend on version 1.6.3-SNAPSHOT 
after having added the following repo:

<repositories>
        <repository>
            <id>sonatype</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
            <snapshots />
        </repository>
</repositories>

Original comment by johan.ha...@gmail.com on 17 Aug 2012 at 6:39