Spring boot : org.codehaus.jackson.map.exc.UnrecognizedPropertyException: Unrecognized field “XX” in WebSphere

China☆狼群 提交于 2019-12-11 17:17:24

问题


I have a spring boot application that execute a reverse Swagger Yaml :

<plugin>
    <groupId>io.swagger</groupId>
    <artifactId>swagger-codegen-maven-plugin</artifactId>
    <version>2.3.1</version>
    <executions>
        <execution>
            <id>generate-swagger-java</id>
            <goals>
                <goal>generate</goal>
            </goals>
            <configuration>
                <inputSpec>${basedir}/src/main/resources/swagger/cview.yaml</inputSpec>
                <apiPackage>client.api</apiPackage>
                <modelPackage>client.model</modelPackage>
                <output>${project.build.directory}/generated-sources</output>
                <language>java</language>
                <configOptions>
                    <dateLibrary>java8</dateLibrary>
                    <library>jersey2</library>
                </configOptions>
            </configuration>
        </execution>
    </executions>
</plugin>

Running with a main class, it works well

public static void main(final String[] args) {
 SpringApplication.run(SpringBootApp.class, args);
}

But when I run it with SpringBootServletInitializer on WebSphere libertyCore it stucks and gives me those errors when I try to call a web service :

org.codehaus.jackson.map.exc.UnrecognizedPropertyException: Unrecognized field "id_entite" (Class client.model.GaEj), not marked as ignorable

Problem with reading the data, class client.model.SearchResultGaEj, ContentType: application/json;charset=UTF-8

the problem is that i dont have any dependency with org.codehaus.jackson.*

I only use com.fasterxml.jackson.datatype


回答1:


By default, WebSphere uses Codehaus Jackson (reference). WebSphere uses two Class-loader modes: Parent first and Parent last. You need to be sure that application uses Jackson from FasterXML not from Codehause. Spring Boot does not have any own managed libraries but WebSphere is an Application Server which provides many already attached libraries so you do not need to provide them with your app.

See:

  1. Catch JsonProcessingException from Jackson in Websphere Liberty
  2. Change Default JSON Provider on WebSphere Application Server
  3. Override Jackson Object Mapper properties on Websphere 8.5.5 using Apache Wink
  4. How to change Jackson version in JAX-RS app (WebSphere Liberty)


来源:https://stackoverflow.com/questions/54668902/spring-boot-org-codehaus-jackson-map-exc-unrecognizedpropertyexception-unreco

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!