Error receiving POST request in Spring with Jackson JSON conversion

I'm new to both Jackson and Spring, so please excuse me if this is a dumb question. I've been working on a simple spring project which handles JSON requests. I have GET and DELETE working, but I'm getting an error when I try to POST:

SEVERE: Servlet.service() for servlet [mvc-dispatcher] in context with path [/CynergyRestStarterKit] threw exception [Handler processing failed; ...with root cause
java.lang.NoSuchMethodError: org.codehaus.jackson.map.type.TypeFactory.type(Ljava/lang/reflect/Type;Lorg/codehaus/jackson/type/JavaType;)Lorg/codehaus/jackson/type/JavaType;
at org.springframework.http.converter.json.MappingJacksonHttpMessageConverter.getJavaType(MappingJacksonHttpMessageConverter.java:229)

Here is my Java service:

@RequestMapping(value = "/todos", method = RequestMethod.GET)
public @ResponseBody
List<TodoItem> getTodos() {     
    return tasks;
}

@RequestMapping(value = "/todo/create", method = RequestMethod.POST)
public @ResponseBody
TodoItem createTodo(@RequestBody TodoItem item) {
    return null;
}

What am I doing wrong?

Answers


What version of Spring and Jackson are you using?

This seems to indicate a version issue.

I see that you are using 1.x of Jackson (codehaus vs fasterxml). I would upgrade both Spring and Jackson to the latest version.


I had the same problem using spring-webmvc 3.2.9, after several retires i found that my project needed the following libraries:

  • jackson-annotations-2.3.3
  • jackson-core-2.3.3
  • jackson-mapper-asl-1.9.13
  • jackson-core-asl-19.3

So adding these solved the problem


Need Your Help

Purpose of factory classes in Java

java design-patterns factory

I have used Java for quite a long time, but I never did find out, what makes factories so special. Can somebody please explain it to me? Is there any reason why I should want to implement my own fa...

Backbone.js - guidance on working with rails and nested collections

javascript ruby-on-rails backbone.js

I'm using codebrew\backbone-rails in a nested model example (say I have a collection of Tasks, and each can have a collection of Details - similar to the example.)

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.