camunda-community-hub / camunda-platform-7-rest-client-spring-boot

Camunda REST client for Java Spring Boot Projects, implemented using Feign
https://camunda-community-hub.github.io/camunda-platform-7-rest-client-spring-boot/
Apache License 2.0
73 stars 22 forks source link

Remove transitive dependency to `com.fasterxml.jackson.module:jackson-module-jaxb-annotations` from starter #444

Closed zambrovski closed 10 months ago

zambrovski commented 11 months ago

Steps to reproduce

Description

The issue popped-up using logstash-logback-encoder providing JSON logs for ELK stack. During the initialization it quits with

java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlElement
    at com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector.<init>(JaxbAnnotationIntrospector.java:137)
    at com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector.<init>(JaxbAnnotationIntrospector.java:124)
    at com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule.setupModule(JaxbAnnotationModule.java:98)
    at com.fasterxml.jackson.databind.ObjectMapper.registerModule(ObjectMapper.java:879)
    at com.fasterxml.jackson.databind.ObjectMapper.registerModules(ObjectMapper.java:1081)
    at com.fasterxml.jackson.databind.ObjectMapper.findAndRegisterModules(ObjectMapper.java:1165)

So I checked the Jackson modules on the classpath and identified com.fasterxml.jackson.module:jackson-module-jaxb-annotations being propagated from camunda-engine-rest-core:7.20 as a transitive dependency:

[INFO] +- org.camunda.bpm:camunda-engine-rest-core:jar:7.20.0:compile
[INFO] |  +- commons-fileupload:commons-fileupload:jar:1.5:compile
[INFO] |  +- commons-io:commons-io:jar:2.8.0:compile
[INFO] |  +- com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:jar:2.15.3:compile
[INFO] |  |  +- com.fasterxml.jackson.jaxrs:jackson-jaxrs-base:jar:2.15.3:compile
[INFO] |  |  \- com.fasterxml.jackson.module:jackson-module-jaxb-annotations:jar:2.15.3:compile
[INFO] |  +- com.fasterxml.jackson.core:jackson-databind:jar:2.15.3:compile
[INFO] |  |  +- com.fasterxml.jackson.core:jackson-annotations:jar:2.15.3:compile
[INFO] |  |  \- com.fasterxml.jackson.core:jackson-core:jar:2.15.3:compile
[INFO] |  \- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.15.3:compile

I analyzed the code of the Jackson Module - it tries to load the JaxbAnnotationIntrospector importing the old annotation class which is not available anymore, once you made a transition to Jakarta world.

Expected behaviour

com.fasterxml.jackson.module:jackson-module-jaxb-annotations is not a transitive dependency.

Actual behaviour

com.fasterxml.jackson.module:jackson-module-jaxb-annotations is a transitive dependency.

Workaround

Exclude the dependency from the classpath.

<dependency>
    <groupId>org.camunda.community.rest</groupId>
    <artifactId>camunda-platform-7-rest-client-spring-boot-starter</artifactId>
    <exclusions>
        <exclusion>
            <groupId>com.fasterxml.jackson.module</groupId>
            <artifactId>jackson-module-jaxb-annotations</artifactId>
        </exclusion>
    </exclusions>
</dependency>

Additional thoughts

Maybe it is a quite good idea to use camunda-bpm-api instead of the full blown engine with transitive dependencies, provided for all possible use cases.

rohwerj commented 11 months ago

Will be resolved by merging #424, as the dependency to camunda-engine-rest-core is not needed anymore

rohwerj commented 10 months ago

Fixed by using camunda-bpm-api and therefore not needing this dependency anymore (see #424)