Jackson issue in Spring.MVC on WildFly server

2019-03-04 02:18发布

I found the question http://stackoverflow.com/questions/38129930/jackson-partial-working-cannot-return-listobject-or-collectionobject for which I was interested in finding out the answer for solving:

11:28:26,333 ERROR [io.undertow.request] (default task-11) UT005023: Exception handling request to /Spring4MVCAngularJSExample/user/: org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.ObjectWriter.forType(Lcom/fasterxml/jackson/databind/JavaType;)Lcom/fasterxml/jackson/databind/ObjectWriter; at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:978) [spring-webmvc-4.3.1.RELEASE.jar:4.3.1.RELEASE] at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897) [spring-webmvc-4.3.1.RELEASE.jar:4.3.1.RELEASE]> at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) [spring-webmvc-4.3.1.RELEASE.jar:4.3.1.RELEASE] at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861) [spring-webmvc-4.3.1.RELEASE.jar:4.3.1.RELEASE] at javax.servlet.http.HttpServlet.service(HttpServlet.java:687) [jboss-servlet-api_3.1_spec-1.0.0.Final.jar:1.0.0.Final] at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) [spring-webmvc-4.3.1.RELEASE.jar:4.3.1.RELEASE] at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) [jboss-servlet-api_3.1_spec-1.0.0.Final.jar:1.0.0.Final] ...

In my case it occurs with the Spring REST API when I use the WAR on a WildFly (8.x) server, but the same WAR on a Tomcat (8.5) server works fine. I am still trying to find a solution in order to have it also working on a WildFly server.

Note that I was following the tutorial spring-mvc-4-angularjs-example but installed initially the WildFly (8.x) server via Eclipse.

I have also modified the POM.xml dependencies as follow hoping to solve the Jackson dependency issue:

<properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <springframework.version>4.3.1.RELEASE</springframework.version>
        <jackson.version>2.7.5</jackson.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${springframework.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>com.fasterxml.jackson.core</groupId>
                    <artifactId>jackson-core</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.fasterxml.jackson.core</groupId>
                    <artifactId>jackson-annotations</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.fasterxml.jackson.core</groupId>
                    <artifactId>jackson-databind</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>${jackson.version}</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.1.0</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>
    </dependencies>

If anyone has an idea, I am all ears.

1条回答
来,给爷笑一个
2楼-- · 2019-03-04 02:32

You should do one thing go inside the wildfly server

\wildfly-8.2.0.Final\modules\system\layers\base\com\fasterxml\jackson\core then go inside check your jar versions it should be 2.8 or above for all core libs. jackson-annotations-2.8.0.jar jackson-core-2.8.3.jar jackson-databind-2.8.3.jar

And change for all jars versions mapping inside the module.xml with latest version name like this

查看更多
登录 后发表回答