Search code examples
spring-bootgradlejacksonbuild.gradlejackson-databind

class com.fasterxml.jackson.dataformat.xml.XmlMapper is loading from from multiple locations


I am puzzled to solve this com.fasterxml.jackson.dataformat.xml.XmlMapper error with Java 11. I want to use XmlMapper only from jackson dependency and that's why excluded from springboot starter web , still cannot figure how to resolve it's dependency. providing as much details as possible -

build.gradle

group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'

configurations {
    compileOnly {
        extendsFrom annotationProcessor
        
    }
    jaxb
    fatJar
}

repositories {
    mavenCentral()
}

dependencies {
    implementation ('org.springframework.boot:spring-boot-starter-web') {
        exclude group: 'com.fasterxml.jackson.core', module: 'jackson-core'
        exclude group: 'com.fasterxml.jackson.core', module: 'jackson-databind'
        exclude group: 'com.fasterxml.jackson.core', module: 'jackson-annotations'
    }
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
    implementation 'org.springframework.boot:spring-boot-starter-actuator'
    compileOnly 'org.projectlombok:lombok:1.18.4'
    annotationProcessor 'org.projectlombok:lombok'
    developmentOnly 'org.springframework.boot:spring-boot-devtools'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
    implementation group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-xml', version: '2.12.2'
    
    compile("com.newrelic.logging:logback:2.0")
    implementation group: 'javax.xml.bind', name: 'jaxb-api', version: '2.2.4'
    jaxb (
        'com.sun.xml.bind:jaxb-xjc:2.3.1',
        'com.sun.xml.bind:jaxb-impl:2.3.1',
        'org.glassfish.jaxb:jaxb-runtime:2.3.3'
    )
}

dependency hierarchy

+--- com.newrelic.logging:logback:2.0
+--- org.springframework.boot:spring-boot-starter-web -> 2.4.5
|    +--- org.springframework.boot:spring-boot-starter:2.4.5
|    |    +--- org.springframework.boot:spring-boot:2.4.5
|    |    |    +--- org.springframework:spring-core:5.3.6
|    |    |    |    \--- org.springframework:spring-jcl:5.3.6
|    |    |    \--- org.springframework:spring-context:5.3.6
|    |    |         +--- org.springframework:spring-aop:5.3.6
|    |    |         |    +--- org.springframework:spring-beans:5.3.6
|    |    |         |    |    \--- org.springframework:spring-core:5.3.6 (*)
|    |    |         |    \--- org.springframework:spring-core:5.3.6 (*)
|    |    |         +--- org.springframework:spring-beans:5.3.6 (*)
|    |    |         +--- org.springframework:spring-core:5.3.6 (*)
|    |    |         \--- org.springframework:spring-expression:5.3.6
|    |    |              \--- org.springframework:spring-core:5.3.6 (*)
|    |    +--- org.springframework.boot:spring-boot-autoconfigure:2.4.5
|    |    |    \--- org.springframework.boot:spring-boot:2.4.5 (*)
|    |    +--- org.springframework.boot:spring-boot-starter-logging:2.4.5
|    |    |    +--- ch.qos.logback:logback-classic:1.2.3
|    |    |    |    +--- ch.qos.logback:logback-core:1.2.3
|    |    |    |    \--- org.slf4j:slf4j-api:1.7.25 -> 1.7.30
|    |    |    +--- org.apache.logging.log4j:log4j-to-slf4j:2.13.3
|    |    |    |    +--- org.slf4j:slf4j-api:1.7.25 -> 1.7.30
|    |    |    |    \--- org.apache.logging.log4j:log4j-api:2.13.3
|    |    |    \--- org.slf4j:jul-to-slf4j:1.7.30
|    |    |         \--- org.slf4j:slf4j-api:1.7.30
|    |    +--- jakarta.annotation:jakarta.annotation-api:1.3.5
|    |    +--- org.springframework:spring-core:5.3.6 (*)
|    |    \--- org.yaml:snakeyaml:1.27
|    +--- org.springframework.boot:spring-boot-starter-json:2.4.5
|    |    +--- org.springframework.boot:spring-boot-starter:2.4.5 (*)
|    |    +--- org.springframework:spring-web:5.3.6
|    |    |    +--- org.springframework:spring-beans:5.3.6 (*)
|    |    |    \--- org.springframework:spring-core:5.3.6 (*)
|    |    +--- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.11.4
|    |    +--- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.11.4
|    |    \--- com.fasterxml.jackson.module:jackson-module-parameter-names:2.11.4
|    +--- org.springframework.boot:spring-boot-starter-tomcat:2.4.5
|    |    +--- jakarta.annotation:jakarta.annotation-api:1.3.5
|    |    +--- org.apache.tomcat.embed:tomcat-embed-core:9.0.45
|    |    +--- org.glassfish:jakarta.el:3.0.3
|    |    \--- org.apache.tomcat.embed:tomcat-embed-websocket:9.0.45
|    |         \--- org.apache.tomcat.embed:tomcat-embed-core:9.0.45
|    +--- org.springframework:spring-web:5.3.6 (*)
|    \--- org.springframework:spring-webmvc:5.3.6
|         +--- org.springframework:spring-aop:5.3.6 (*)
|         +--- org.springframework:spring-beans:5.3.6 (*)
|         +--- org.springframework:spring-context:5.3.6 (*)
|         +--- org.springframework:spring-core:5.3.6 (*)
|         +--- org.springframework:spring-expression:5.3.6 (*)
|         \--- org.springframework:spring-web:5.3.6 (*)
+--- org.springframework.boot:spring-boot-starter-actuator -> 2.4.5
|    +--- org.springframework.boot:spring-boot-starter:2.4.5 (*)
|    +--- org.springframework.boot:spring-boot-actuator-autoconfigure:2.4.5
|    |    +--- org.springframework.boot:spring-boot-actuator:2.4.5
|    |    |    \--- org.springframework.boot:spring-boot:2.4.5 (*)
|    |    +--- org.springframework.boot:spring-boot:2.4.5 (*)
|    |    \--- org.springframework.boot:spring-boot-autoconfigure:2.4.5 (*)
|    \--- io.micrometer:micrometer-core:1.6.6
|         \--- org.hdrhistogram:HdrHistogram:2.1.12
+--- com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.12.2
|    +--- com.fasterxml.jackson.core:jackson-core:2.12.2 -> 2.11.4
|    +--- com.fasterxml.jackson.core:jackson-annotations:2.12.2 -> 2.11.4
|    +--- com.fasterxml.jackson.core:jackson-databind:2.12.2 -> 2.11.4
|    |    +--- com.fasterxml.jackson.core:jackson-annotations:2.11.4
|    |    \--- com.fasterxml.jackson.core:jackson-core:2.11.4
|    +--- com.fasterxml.jackson.module:jackson-module-jaxb-annotations:2.12.2 -> 2.11.4
|    |    +--- com.fasterxml.jackson.core:jackson-annotations:2.11.4
|    |    +--- com.fasterxml.jackson.core:jackson-core:2.11.4
|    |    +--- com.fasterxml.jackson.core:jackson-databind:2.11.4 (*)
|    |    +--- jakarta.xml.bind:jakarta.xml.bind-api:2.3.2 -> 2.3.3
|    |    |    \--- jakarta.activation:jakarta.activation-api:1.2.2
|    |    \--- jakarta.activation:jakarta.activation-api:1.2.1 -> 1.2.2
|    +--- org.codehaus.woodstox:stax2-api:4.2.1
|    +--- com.fasterxml.woodstox:woodstox-core:6.2.4
|    |    \--- org.codehaus.woodstox:stax2-api:4.2.1
|    \--- com.fasterxml.jackson:jackson-bom:2.12.2
|         +--- com.fasterxml.jackson.core:jackson-annotations:2.12.2 -> 2.11.4 (c)
|         +--- com.fasterxml.jackson.core:jackson-core:2.12.2 -> 2.11.4 (c)
|         +--- com.fasterxml.jackson.core:jackson-databind:2.12.2 -> 2.11.4 (c)
|         +--- com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.12.2 (c)
|         +--- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.12.2 -> 2.11.4 (c)
|         +--- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.12.2 -> 2.11.4 (c)
|         +--- com.fasterxml.jackson.module:jackson-module-jaxb-annotations:2.12.2 -> 2.11.4 (c)
|         \--- com.fasterxml.jackson.module:jackson-module-parameter-names:2.12.2 -> 2.11.4 (c)
+--- javax.xml.bind:jaxb-api:2.2.4
|    +--- javax.xml.stream:stax-api:1.0-2
|    \--- javax.activation:activation:1.1
\--- org.springframework.boot:spring-boot-starter-test -> 2.4.5
     +--- org.springframework.boot:spring-boot-starter:2.4.5 (*)
     +--- org.springframework.boot:spring-boot-test:2.4.5
     |    \--- org.springframework.boot:spring-boot:2.4.5 (*)
     +--- org.springframework.boot:spring-boot-test-autoconfigure:2.4.5
     |    +--- org.springframework.boot:spring-boot:2.4.5 (*)
     |    +--- org.springframework.boot:spring-boot-test:2.4.5 (*)
     |    \--- org.springframework.boot:spring-boot-autoconfigure:2.4.5 (*)
     +--- com.jayway.jsonpath:json-path:2.4.0
     |    +--- net.minidev:json-smart:2.3
     |    |    \--- net.minidev:accessors-smart:1.2
     |    |         \--- org.ow2.asm:asm:5.0.4
     |    \--- org.slf4j:slf4j-api:1.7.25 -> 1.7.30
     +--- jakarta.xml.bind:jakarta.xml.bind-api:2.3.3 (*)
     +--- org.assertj:assertj-core:3.18.1
     +--- org.hamcrest:hamcrest:2.2
     +--- org.junit.jupiter:junit-jupiter:5.7.1
     |    +--- org.junit:junit-bom:5.7.1
     |    |    +--- org.junit.jupiter:junit-jupiter:5.7.1 (c)
     |    |    +--- org.junit.jupiter:junit-jupiter-api:5.7.1 (c)
     |    |    +--- org.junit.jupiter:junit-jupiter-params:5.7.1 (c)
     |    |    \--- org.junit.platform:junit-platform-commons:1.7.1 (c)
     |    +--- org.junit.jupiter:junit-jupiter-api:5.7.1
     |    |    +--- org.junit:junit-bom:5.7.1 (*)
     |    |    +--- org.apiguardian:apiguardian-api:1.1.0
     |    |    +--- org.opentest4j:opentest4j:1.2.0
     |    |    \--- org.junit.platform:junit-platform-commons:1.7.1
     |    |         +--- org.junit:junit-bom:5.7.1 (*)
     |    |         \--- org.apiguardian:apiguardian-api:1.1.0
     |    \--- org.junit.jupiter:junit-jupiter-params:5.7.1
     |         +--- org.junit:junit-bom:5.7.1 (*)
     |         +--- org.apiguardian:apiguardian-api:1.1.0
     |         \--- org.junit.jupiter:junit-jupiter-api:5.7.1 (*)
     +--- org.mockito:mockito-core:3.6.28
     |    +--- net.bytebuddy:byte-buddy:1.10.18 -> 1.10.22
     |    +--- net.bytebuddy:byte-buddy-agent:1.10.18 -> 1.10.22
     |    \--- org.objenesis:objenesis:3.1
     +--- org.mockito:mockito-junit-jupiter:3.6.28
     |    \--- org.mockito:mockito-core:3.6.28 (*)
     +--- org.skyscreamer:jsonassert:1.5.0
     |    \--- com.vaadin.external.google:android-json:0.0.20131108.vaadin1
     +--- org.springframework:spring-core:5.3.6 (*)
     +--- org.springframework:spring-test:5.3.6
     |    \--- org.springframework:spring-core:5.3.6 (*)
     \--- org.xmlunit:xmlunit-core:2.7.0

testCompileOnly - Compile only dependencies for source set 'test'. (n)
No dependencies

testImplementation - Implementation only dependencies for source set 'test'. (n)
\--- org.springframework.boot:spring-boot-starter-test (n)

testRuntimeClasspath - Runtime classpath of source set 'test'.
+--- com.newrelic.logging:logback:2.0
|    +--- com.fasterxml.jackson.core:jackson-core:2.11.1 -> 2.11.4
|    +--- ch.qos.logback:logback-core:1.2.0 -> 1.2.3
|    +--- ch.qos.logback:logback-classic:1.2.0 -> 1.2.3
|    |    +--- ch.qos.logback:logback-core:1.2.3
|    |    \--- org.slf4j:slf4j-api:1.7.25 -> 1.7.30
|    \--- com.newrelic.agent.java:newrelic-api:5.6.0
+--- org.springframework.boot:spring-boot-starter-web -> 2.4.5
|    +--- org.springframework.boot:spring-boot-starter:2.4.5
|    |    +--- org.springframework.boot:spring-boot:2.4.5
|    |    |    +--- org.springframework:spring-core:5.3.6
|    |    |    |    \--- org.springframework:spring-jcl:5.3.6
|    |    |    \--- org.springframework:spring-context:5.3.6
|    |    |         +--- org.springframework:spring-aop:5.3.6
|    |    |         |    +--- org.springframework:spring-beans:5.3.6
|    |    |         |    |    \--- org.springframework:spring-core:5.3.6 (*)
|    |    |         |    \--- org.springframework:spring-core:5.3.6 (*)
|    |    |         +--- org.springframework:spring-beans:5.3.6 (*)
|    |    |         +--- org.springframework:spring-core:5.3.6 (*)
|    |    |         \--- org.springframework:spring-expression:5.3.6
|    |    |              \--- org.springframework:spring-core:5.3.6 (*)
|    |    +--- org.springframework.boot:spring-boot-autoconfigure:2.4.5
|    |    |    \--- org.springframework.boot:spring-boot:2.4.5 (*)
|    |    +--- org.springframework.boot:spring-boot-starter-logging:2.4.5
|    |    |    +--- ch.qos.logback:logback-classic:1.2.3 (*)
|    |    |    +--- org.apache.logging.log4j:log4j-to-slf4j:2.13.3
|    |    |    |    +--- org.slf4j:slf4j-api:1.7.25 -> 1.7.30
|    |    |    |    \--- org.apache.logging.log4j:log4j-api:2.13.3
|    |    |    \--- org.slf4j:jul-to-slf4j:1.7.30
|    |    |         \--- org.slf4j:slf4j-api:1.7.30
|    |    +--- jakarta.annotation:jakarta.annotation-api:1.3.5
|    |    +--- org.springframework:spring-core:5.3.6 (*)
|    |    \--- org.yaml:snakeyaml:1.27
|    +--- org.springframework.boot:spring-boot-starter-json:2.4.5
|    |    +--- org.springframework.boot:spring-boot-starter:2.4.5 (*)
|    |    +--- org.springframework:spring-web:5.3.6
|    |    |    +--- org.springframework:spring-beans:5.3.6 (*)
|    |    |    \--- org.springframework:spring-core:5.3.6 (*)
|    |    +--- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.11.4
|    |    +--- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.11.4
|    |    |    +--- com.fasterxml.jackson.core:jackson-annotations:2.11.4
|    |    |    +--- com.fasterxml.jackson.core:jackson-core:2.11.4
|    |    |    \--- com.fasterxml.jackson.core:jackson-databind:2.11.4
|    |    |         +--- com.fasterxml.jackson.core:jackson-annotations:2.11.4
|    |    |         \--- com.fasterxml.jackson.core:jackson-core:2.11.4
|    |    \--- com.fasterxml.jackson.module:jackson-module-parameter-names:2.11.4
|    +--- org.springframework.boot:spring-boot-starter-tomcat:2.4.5
|    |    +--- jakarta.annotation:jakarta.annotation-api:1.3.5
|    |    +--- org.apache.tomcat.embed:tomcat-embed-core:9.0.45
|    |    +--- org.glassfish:jakarta.el:3.0.3
|    |    \--- org.apache.tomcat.embed:tomcat-embed-websocket:9.0.45
|    |         \--- org.apache.tomcat.embed:tomcat-embed-core:9.0.45
|    +--- org.springframework:spring-web:5.3.6 (*)
|    \--- org.springframework:spring-webmvc:5.3.6
|         +--- org.springframework:spring-aop:5.3.6 (*)
|         +--- org.springframework:spring-beans:5.3.6 (*)
|         +--- org.springframework:spring-context:5.3.6 (*)
|         +--- org.springframework:spring-core:5.3.6 (*)
|         +--- org.springframework:spring-expression:5.3.6 (*)
|         \--- org.springframework:spring-web:5.3.6 (*)
+--- org.springframework.boot:spring-boot-starter-actuator -> 2.4.5
|    +--- org.springframework.boot:spring-boot-starter:2.4.5 (*)
|    +--- org.springframework.boot:spring-boot-actuator-autoconfigure:2.4.5
|    |    +--- com.fasterxml.jackson.core:jackson-databind:2.11.4 (*)
|    |    +--- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.11.4 (*)
|    |    +--- org.springframework.boot:spring-boot-actuator:2.4.5
|    |    |    \--- org.springframework.boot:spring-boot:2.4.5 (*)
|    |    +--- org.springframework.boot:spring-boot:2.4.5 (*)
|    |    \--- org.springframework.boot:spring-boot-autoconfigure:2.4.5 (*)
|    \--- io.micrometer:micrometer-core:1.6.6
|         +--- org.hdrhistogram:HdrHistogram:2.1.12
|         \--- org.latencyutils:LatencyUtils:2.0.3
+--- com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.12.2
|    +--- com.fasterxml.jackson.core:jackson-core:2.12.2 -> 2.11.4
|    +--- com.fasterxml.jackson.core:jackson-annotations:2.12.2 -> 2.11.4
|    +--- com.fasterxml.jackson.core:jackson-databind:2.12.2 -> 2.11.4 (*)
|    +--- com.fasterxml.jackson.module:jackson-module-jaxb-annotations:2.12.2 -> 2.11.4
|    |    +--- com.fasterxml.jackson.core:jackson-annotations:2.11.4
|    |    +--- com.fasterxml.jackson.core:jackson-core:2.11.4
|    |    +--- com.fasterxml.jackson.core:jackson-databind:2.11.4 (*)
|    |    +--- jakarta.xml.bind:jakarta.xml.bind-api:2.3.2 -> 2.3.3
|    |    |    \--- jakarta.activation:jakarta.activation-api:1.2.2
|    |    \--- jakarta.activation:jakarta.activation-api:1.2.1 -> 1.2.2
|    +--- org.codehaus.woodstox:stax2-api:4.2.1
|    +--- com.fasterxml.woodstox:woodstox-core:6.2.4
|    |    \--- org.codehaus.woodstox:stax2-api:4.2.1
|    \--- com.fasterxml.jackson:jackson-bom:2.12.2
|         +--- com.fasterxml.jackson.core:jackson-annotations:2.12.2 -> 2.11.4 (c)
|         +--- com.fasterxml.jackson.core:jackson-core:2.12.2 -> 2.11.4 (c)
|         +--- com.fasterxml.jackson.core:jackson-databind:2.12.2 -> 2.11.4 (c)
|         +--- com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.12.2 (c)
|         +--- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.12.2 -> 2.11.4 (c)
|         +--- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.12.2 -> 2.11.4 (c)
|         +--- com.fasterxml.jackson.module:jackson-module-jaxb-annotations:2.12.2 -> 2.11.4 (c)
|         \--- com.fasterxml.jackson.module:jackson-module-parameter-names:2.12.2 -> 2.11.4 (c)
+--- javax.xml.bind:jaxb-api:2.2.4
|    +--- javax.xml.stream:stax-api:1.0-2
|    \--- javax.activation:activation:1.1
\--- org.springframework.boot:spring-boot-starter-test -> 2.4.5
     +--- org.springframework.boot:spring-boot-starter:2.4.5 (*)
     +--- org.springframework.boot:spring-boot-test:2.4.5
     |    \--- org.springframework.boot:spring-boot:2.4.5 (*)
     +--- org.springframework.boot:spring-boot-test-autoconfigure:2.4.5
     |    +--- org.springframework.boot:spring-boot:2.4.5 (*)
     |    +--- org.springframework.boot:spring-boot-test:2.4.5 (*)
     |    \--- org.springframework.boot:spring-boot-autoconfigure:2.4.5 (*)
     +--- com.jayway.jsonpath:json-path:2.4.0
     |    +--- net.minidev:json-smart:2.3
     |    |    \--- net.minidev:accessors-smart:1.2
     |    |         \--- org.ow2.asm:asm:5.0.4
     |    \--- org.slf4j:slf4j-api:1.7.25 -> 1.7.30
     +--- jakarta.xml.bind:jakarta.xml.bind-api:2.3.3 (*)
     +--- org.assertj:assertj-core:3.18.1
     +--- org.hamcrest:hamcrest:2.2
     +--- org.junit.jupiter:junit-jupiter:5.7.1
     |    +--- org.junit:junit-bom:5.7.1
     |    |    +--- org.junit.jupiter:junit-jupiter:5.7.1 (c)
     |    |    +--- org.junit.jupiter:junit-jupiter-api:5.7.1 (c)
     |    |    +--- org.junit.jupiter:junit-jupiter-engine:5.7.1 (c)
     |    |    +--- org.junit.jupiter:junit-jupiter-params:5.7.1 (c)
     |    |    +--- org.junit.platform:junit-platform-commons:1.7.1 (c)
     |    |    \--- org.junit.platform:junit-platform-engine:1.7.1 (c)
     |    +--- org.junit.jupiter:junit-jupiter-api:5.7.1
     |    |    +--- org.junit:junit-bom:5.7.1 (*)
     |    |    +--- org.apiguardian:apiguardian-api:1.1.0
     |    |    +--- org.opentest4j:opentest4j:1.2.0
     |    |    \--- org.junit.platform:junit-platform-commons:1.7.1
     |    |         +--- org.junit:junit-bom:5.7.1 (*)
     |    |         \--- org.apiguardian:apiguardian-api:1.1.0
     |    +--- org.junit.jupiter:junit-jupiter-params:5.7.1
     |    |    +--- org.junit:junit-bom:5.7.1 (*)
     |    |    +--- org.apiguardian:apiguardian-api:1.1.0
     |    |    \--- org.junit.jupiter:junit-jupiter-api:5.7.1 (*)
     |    \--- org.junit.jupiter:junit-jupiter-engine:5.7.1
     |         +--- org.junit:junit-bom:5.7.1 (*)
     |         +--- org.apiguardian:apiguardian-api:1.1.0
     |         +--- org.junit.platform:junit-platform-engine:1.7.1
     |         |    +--- org.junit:junit-bom:5.7.1 (*)
     |         |    +--- org.apiguardian:apiguardian-api:1.1.0
     |         |    +--- org.opentest4j:opentest4j:1.2.0
     |         |    \--- org.junit.platform:junit-platform-commons:1.7.1 (*)
     |         \--- org.junit.jupiter:junit-jupiter-api:5.7.1 (*)
     +--- org.mockito:mockito-core:3.6.28
     |    +--- net.bytebuddy:byte-buddy:1.10.18 -> 1.10.22
     |    +--- net.bytebuddy:byte-buddy-agent:1.10.18 -> 1.10.22
     |    \--- org.objenesis:objenesis:3.1
     +--- org.mockito:mockito-junit-jupiter:3.6.28
     |    +--- org.mockito:mockito-core:3.6.28 (*)
     |    \--- org.junit.jupiter:junit-jupiter-api:5.4.2 -> 5.7.1 (*)
     +--- org.skyscreamer:jsonassert:1.5.0
     |    \--- com.vaadin.external.google:android-json:0.0.20131108.vaadin1
     +--- org.springframework:spring-core:5.3.6 (*)
     +--- org.springframework:spring-test:5.3.6
     |    \--- org.springframework:spring-core:5.3.6 (*)
     \--- org.xmlunit:xmlunit-core:2.7.0

Error while running the boot app -

Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

    com.fasterxml.jackson.dataformat.xml.XmlMapper.<init>(XmlMapper.java:175)

The following method did not exist:

    'com.fasterxml.jackson.databind.cfg.MutableCoercionConfig com.fasterxml.jackson.dataformat.xml.XmlMapper.coercionConfigDefaults()'

The method's class, com.fasterxml.jackson.dataformat.xml.XmlMapper, is available from the following locations:

    jar:file:/C:/Users/user1/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.dataformat/jackson-dataformat-xml/2.12.2/dac1d21b5fe602d492273d35eb28918a91fc5412/jackson-dataformat-xml-2.12.2.jar!/com/fasterxml/jackson/dataformat/xml/XmlMapper.class

The class hierarchy was loaded from the following locations:

    com.fasterxml.jackson.dataformat.xml.XmlMapper: file:/C:/Users/user1/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.dataformat/jackson-dataformat-xml/2.12.2/dac1d21b5fe602d492273d35eb28918a91fc5412/jackson-dataformat-xml-2.12.2.jar
    com.fasterxml.jackson.databind.ObjectMapper: file:/C:/Users/user1/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-databind/2.11.4/5d9f3d441f99d721b957e3497f0a6465c764fad4/jackson-databind-2.11.4.jar
    com.fasterxml.jackson.core.ObjectCodec: file:/C:/Users/user1/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-core/2.11.4/593f7b18bab07a76767f181e2a2336135ce82cc4/jackson-core-2.11.4.jar
    com.fasterxml.jackson.core.TreeCodec: file:/C:/Users/user1/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-core/2.11.4/593f7b18bab07a76767f181e2a2336135ce82cc4/jackson-core-2.11.4.jar


Action:

Correct the classpath of your application so that it contains a single, compatible version of com.fasterxml.jackson.dataformat.xml.XmlMapper

Solution

  • Do you explicitly need version 2.12.2 of jackson-dataformat-xml?

    Problem

    jackson-dataformat-xml:2.12.2 is not compatible with jackson dependencies 2.11.4. Spring Boot overwrites Jackson dependencies that are not specified other way in dependencies block or in dependencyManagement.

    Solution

    If you don't need 2.12.2 then just define the jackson-dataformat-xml as following:

      implementation group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-xml'
    

    then resolved version will be

    com.fasterxml.jackson.dataformat:jackson-dataformat-xml -> 2.11.4
    

    which will be compatible with all other Jackson components and you will not be getting this exception anymore. Always try to check the dependencies of Jackson and make sure all are aligned.

    You see for example if you run 'gradlew dependencies' and you get following result it's bad:

    +--- com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.12.2
    |    +--- com.fasterxml.jackson.core:jackson-core:2.12.2 -> 2.11.4
    

    versions of Jackson are not properly aligned. With managing Gradle dependencies you have to make sure you aligne them, that means upgrading or downgrading them.

    If you really need explicitly 2.12.2 then you should also upgrade Spring Boot version which contains newer version.

    You can specify version of Spring Boot in following way:

    dependencyManagement {
      imports {
        mavenBom 'org.springframework.boot:spring-boot-dependencies:2.5.0'
      }
    }