Reputation: 8704
I have following class which i am returning from spring rest server
public class Message {
private String name;
private String text;
public Message(String name, String text) {
this.name = name;
this.text = text;
}
public String getName() {
return name;
}
public String getText() {
return text;
}
}
And I am getting following error when i try to access the api
g.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.type.TypeFactory.constructType(Ljava/lang/reflect/Type;Ljava/lang/Class;)Lcom/fasterxml/jackson/databind/JavaType;
org.springframework.web.servlet.DispatcherServlet.triggerAfterCompletionWithError(DispatcherServlet.java:1302)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:977)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:969)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:860)
javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:845)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
here is my jackson mapping tree via mvn dependency:tree | grep jackson
[INFO] +- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.9:compile
[INFO] | \- org.codehaus.jackson:jackson-core-asl:jar:1.9.9:compile
[INFO] \- com.fasterxml.jackson.core:jackson-databind:jar:2.7.0:compile
[INFO] +- com.fasterxml.jackson.core:jackson-annotations:jar:2.7.0:compile
[INFO] \- com.fasterxml.jackson.core:jackson-core:jar:2.7.0:compile
and here is my actual jackson dependency in pom.xml
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.9</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.7.0</version>
</dependency>
I have tried including latest version of both libraries. I am not sure what i am missing here.
Upvotes: 4
Views: 5214
Reputation: 59096
Which Spring version are you using? Check out the library requirements for Spring on the Spring wiki.
If you're using Spring 4+, you don't need org.codehaus
dependencies.
Now there are some issues with Jackson 2.7 - this version will be supported in Spring 4.3 (see SPR-13728 and SPR-13483). In the meantime, you should stick to Jackson 2.6+.
Upvotes: 3