Jackson Throws a Nose Method Error

I have the following class that I am returning from a 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 get the 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 through 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 tried to include the latest version of both libraries. I'm not sure what is missing here.

+4
source share
1 answer

What version of Spring are you using? Check out the library requirements for Spring on the Spring wiki.

If you use Spring 4+, you do not need dependencies org.codehaus.

Jackson 2.7 - Spring 4.3 (. SPR-13728 SPR-13483). Jackson 2.6 +.

+3

All Articles