I\'ve tried to have a controller in Spring return a JSON response to no avail using the Jackson classes as recommended with 3.0. I\'ve got the jackson jar files(jackson-core
Also, make sure that you add two jackson related jar files.
jackson-core-asl-1.9.8.jar
jackson-mapper-asl-1.9.8.jar
The version can be different.
I know that this is an old thread, but maybe someone will encounter the same problem as me. I got that exception when migrating an application from Spring 4.0.3.RELEASE to Spring 4.1.0.RELEASE. In my case updating Jackson from 1.9.x to 2.4.x did the trick.
Sending the Accept: application/xml header does not work. But sending Accept: application/json actually works, and jackson mapper kicks in. I got rid of my 406 and got my serialized java object in json format with no more config than @ResponseBody and return new MyObject() :) Thanks skaffman for this information, and thanks Bozho for the working header value :D
Get rid of all Jackson beans, and of the json mapping in the negotiating resolver. the mvc:annotation-driven
should configure everything you need for the Jackson serialization to work.
May be my answer is a bit late, but it may help some one else visiting this question.
I got my problem resolved by adding
hibernate-validator-4.0.2
and gave me another exception (class not found exception: org.slf4j.LoggerFactory) which i resolved by adding
slf4j-api-1.5.6.jar
I hope it will help someone.
I have got same exception when migrating from spring 3.x to spring 4.x.
I solved it with updating jackson dependencies from
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.13</version>
</dependency>
to
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.5.1</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.5.1</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.5.1</version>
</dependency>
Nothing else was needed for me.