简体   繁体   English

杰克逊错误 com.fasterxml.jackson.databind.ser.ContainerSerializer: 方法<init> (Lcom/fasterxml/jackson/databind/JavaType;)V 未找到

[英]Jackson error com.fasterxml.jackson.databind.ser.ContainerSerializer: method <init>(Lcom/fasterxml/jackson/databind/JavaType;)V not found

I am having a problem deploying a Spring MVC application using Spring Data JPA in Wildfly 8.2.1 and Glassfish 4.1 (It works in Wildfly 10, but i'm not allowed to use it).我在 Wildfly 8.2.1 和 Glassfish 4.1 中使用 Spring Data JPA 部署 Spring MVC 应用程序时遇到问题(它适用于 Wildfly 10,但我不允许使用它)。

Here is the StackTrace这是堆栈跟踪

    Stack Trace
org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.NoSuchMethodError:   com.fasterxml.jackson.databind.ser.ContainerSerializer: method <init>(Lcom/fasterxml/jackson/databind/JavaType;)V not found
org.springframework.web.servlet.DispatcherServlet.triggerAfterCompletionWithError(DispatcherServlet.java:1303)
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:970)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861)
javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:86)
io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)
io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:58)
io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:70)
io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76)
io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:261)
io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:248)
io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:77)
io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:167)
io.undertow.server.Connectors.executeRootHandler(Connectors.java:199)
io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:761)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
java.lang.Thread.run(Thread.java:745)

My POM:我的POM:

   <dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
    </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>
    <!-- https://mvnrepository.com/artifact/javax.mail/mail -->
    <dependency>
        <groupId>javax.mail</groupId>
        <artifactId>mail</artifactId>
        <version>1.4</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.springframework/spring-context-support -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context-support</artifactId>
        <version>4.3.3.RELEASE</version>
    </dependency>

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-validator</artifactId>
        <version>4.3.2.Final</version>
    </dependency>
    <dependency>
        <groupId>javax.validation</groupId>
        <artifactId>validation-api</artifactId>
        <version>1.0.0.GA</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-orm</artifactId>
        <version>4.2.1.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>4.2.1.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-tx</artifactId>
        <version>4.2.1.RELEASE</version>
    </dependency>
                    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-aop</artifactId>
        <version>4.2.9.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>commons-fileupload</groupId>
        <artifactId>commons-fileupload</artifactId>
        <version>1.2.2</version>
    </dependency>
    <dependency>
        <groupId>commons-io</groupId>
        <artifactId>commons-io</artifactId>
        <version>2.0</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>4.2.1.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>commons-dbcp</groupId>
        <artifactId>commons-dbcp</artifactId>
        <version>1.4</version>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-core</artifactId>
        <version>2.8.3</version>
    </dependency>

    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>2.8.3</version>
    </dependency>

    <dependency>
        <groupId>com.fasterxml.jackson.datatype</groupId>
        <artifactId>jackson-datatype-hibernate4</artifactId>
        <version>2.8.3</version>
    </dependency>
    <dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
        <version>2.3</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>4.3.11.Final</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>4.3.11.Final</version>
    </dependency>
    <!-- ... other dependency elements ... -->


    <!-- Chat -->
    <dependency>
        <groupId>org.cometd.java</groupId>
        <artifactId>bayeux-api</artifactId>
        <version>2.5.0</version>
    </dependency>
    <dependency>
        <groupId>org.cometd.java</groupId>
        <artifactId>cometd-java-server</artifactId>
        <version>2.5.0</version>
    </dependency>
    <dependency>
        <groupId>org.cometd.java</groupId>
        <artifactId>cometd-websocket-jetty</artifactId>
        <version>2.5.0</version>
        <exclusions>
            <exclusion>
                <groupId>org.cometd.java</groupId>
                <artifactId>cometd-java-client</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-simple</artifactId>
        <version>1.6.6</version>
    </dependency>
    <dependency>
        <groupId>org.cometd.java</groupId>
        <artifactId>cometd-java-annotations</artifactId>
        <version>2.5.0</version>
    </dependency>
    <dependency>
    <groupId>org.springframework.data</groupId>
    <artifactId>spring-data-mongodb</artifactId>
    <version>1.9.5.RELEASE</version>
</dependency>
<!-- Log4j -->
<dependency>
    <groupId>log4j</groupId>
    <artifactId>log4j</artifactId>
    <version>1.2.17</version>
</dependency>
            <dependency>
        <groupId>org.postgresql</groupId>
        <artifactId>postgresql</artifactId>
        <version>9.4.1212.jre7</version>
    </dependency>
    <dependency>
        <groupId>org.apache.tomcat</groupId>
        <artifactId>tomcat-dbcp</artifactId>
        <version>7.0.55</version>
    </dependency>
    <dependency>
        <groupId>javax.transaction</groupId>
        <artifactId>jta</artifactId>
        <version>1.1</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-jpa</artifactId>
        <version>1.10.6.RELEASE</version>
        <type>jar</type>
    </dependency>
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-web-api</artifactId>
        <version>7.0</version>
        <type>jar</type>
    </dependency>
</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.6.0</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
                <compilerArguments>
                    <endorseddirs>${endorsed.dir}</endorseddirs>
                </compilerArguments>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.3</version>
            <configuration>
                <failOnMissingWebXml>false</failOnMissingWebXml>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.6</version>
            <executions>
                <execution>
                    <phase>validate</phase>
                    <goals>
                        <goal>copy</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>${endorsed.dir}  </outputDirectory>
                        <silent>true</silent>
                        <artifactItems>
                            <artifactItem>
                                <groupId>javax</groupId>
                                <artifactId>javaee-endorsed-api</artifactId>
                                <version>7.0</version>
                                <type>jar</type>
                            </artifactItem>
                        </artifactItems>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

I've tested this in both wildfly 8.2.1 and Glassfish 4.1 having the same problem, but it works fine in Wildfly 10, the problem is my office already uses Wildfly 8.2.1 and they dont want to change the version.我已经在wildfly 8.2.1 和Glassfish 4.1 中测试了这个问题,但它在Wildfly 10 中运行良好,问题是我的办公室已经使用了Wildfly 8.2.1,他们不想更改版本。 If anyone has any idea of why this does not work i would really appreciate it, and if you need any more data i would gladly provide it.如果有人知道为什么这不起作用,我将不胜感激,如果您需要更多数据,我很乐意提供。 Thanks in advance.提前致谢。

Probably the container has already an older version of Jackson and that is making class loading problems.可能容器已经有一个旧版本的 Jackson,这会导致类加载问题。

A way to solve that can be specifying a jboss-deployment-structure.xml file.一种解决方法是指定一个jboss-deployment-structure.xml文件。 That way you can "inject" your dependencies with higher priority.这样您就可以以更高的优先级“注入”您的依赖项。 See this classloading problems with Wildfly 8.0.0 for more details and example.有关更多详细信息和示例,请参阅Wildfly 8.0.0 的类加载问题

As in documentation in order of highest priority to lowest priority of class loading:如文档中按类加载的最高优先级到最低优先级的顺序:

System Dependencies - These are dependencies that are added to the module automatically by the container, including the Java EE api's.系统依赖项- 这些依赖项由容器自动添加到模块中,包括 Java EE api。

User Dependencies - These are dependencies that are added through jboss-deployment-structure.xml or through the Dependencies: manifest entry.用户依赖项- 这些依赖项是通过 jboss-deployment-structure.xml 或通过 Dependencies: manifest 条目添加的。

Local Resource - Class files packaged up inside the deployment itself, eg class files from WEB-INF/classes or WEB-INF/lib of a war.本地资源- 打包在部署内部的类文件,例如来自 WEB-INF/classes 或 WEB-INF/lib 的类文件。

Inter deployment dependencies - These are dependencies on other deployments in an ear deployment.部署间依赖关系- 这些是在 Ear 部署中对其他部署的依赖关系。 This can include classes in an ear's lib directory, or classes defined in other ejb jars.这可以包括ear 的lib 目录中的类,或者其他ejb jar 中定义的类。

See https://docs.jboss.org/author/display/WFLY8/Class+Loading+in+WildFly?_sscc=t for more deatils.有关更多详细信息,请参阅https://docs.jboss.org/author/display/WFLY8/Class+Loading+in+WildFly?_sscc=t

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/ser/FilterProvider - java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/ser/FilterProvider com.fasterxml.jackson.databind.ser.BeanSerializer.serialize Spring JPA - com.fasterxml.jackson.databind.ser.BeanSerializer.serialize Spring JPA 错误:com.fasterxml.jackson.databind.JsonMappingException:未找到序列化程序 - error: com.fasterxml.jackson.databind.JsonMappingException: No serializer found 引起:java.lang.ClassNotFoundException: com.fasterxml.jackson.databind.JavaType not found - Caused by: java.lang.ClassNotFoundException: com.fasterxml.jackson.databind.JavaType not found Fasterxml Jackson 数据绑定 MismatchedInputException - Fasterxml Jackson databind MismatchedInputException 服务器崩溃并出现错误:com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields - Server crashes with the error: com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields com.fasterxml.jackson.databind.exc.MismatchedInputException - com.fasterxml.jackson.databind.exc.MismatchedInputException com / fasterxml / jackson / databind / ObjectMapper的Android NoClassDefFoundError - Android NoClassDefFoundError for com/fasterxml/jackson/databind/ObjectMapper com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException - com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException com/fasterxml/jackson/databind/ObjectMapper 与 Maven 的 NoClassDefFoundError - NoClassDefFoundError of com/fasterxml/jackson/databind/ObjectMapper with Maven
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM