Closed frankjkelly closed 1 month ago
The reason is in the Pom.xml
<dependency>
<groupId>com.fasterxml.jackson</groupId>
<artifactId>jackson-bom</artifactId>
<version>${jackson.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
This includes jackson-module-jaxb-annotations-${jackson.version}.jar, which is then automatically discovered by jackson.
Thanks @jowi-ppi - is there any way around it?
That is not exactly correct. The jackson-bom
is used in logstash-logback-encoder's dependencyManagement
section. Not its dependencies
section. Therefore logstash-logback-encoder does not depend on, or require, jackson-module-jaxb-annotations
.
This can be confirmed by viewing the runtime dependency tree for logstash-logback-encoder (including optional dependencies).
❯ mvn dependency:tree -Dscope=runtime
[INFO] Scanning for projects...
[INFO]
[INFO] -----------< net.logstash.logback:logstash-logback-encoder >------------
[INFO] Building Logstash Logback Encoder 7.4
[INFO] from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- dependency:3.6.0:tree (default-cli) @ logstash-logback-encoder ---
[INFO] net.logstash.logback:logstash-logback-encoder:jar:7.4
[INFO] +- ch.qos.logback:logback-classic:jar:1.3.7:compile
[INFO] | \- org.slf4j:slf4j-api:jar:2.0.4:compile
[INFO] +- ch.qos.logback:logback-access:jar:1.3.7:compile
[INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.15.2:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.15.2:compile
[INFO] | \- com.fasterxml.jackson.core:jackson-core:jar:2.15.2:compile
[INFO] +- com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:jar:2.15.2:compile
[INFO] +- com.fasterxml.jackson.dataformat:jackson-dataformat-smile:jar:2.15.2:compile
[INFO] +- com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:jar:2.15.2:compile
[INFO] | \- org.yaml:snakeyaml:jar:2.0:compile
[INFO] +- com.fasterxml.uuid:java-uuid-generator:jar:4.2.0:compile
[INFO] \- com.lmax:disruptor:jar:3.4.4:compile
By default, logstash-logback-encoder will tell jackson to dynamically discover all available jackson modules on the classpath by calling objectMapper.findAndRegisterModules()
, as seen in your stacktrace. In your case, the jackson-module-jaxb-annotations
is on your runtime classpath, and jackson is trying to register it, and failing due to one of its required dependencies being missing. Something else in your application (not logstash-logback-encoder) is putting jackson-module-jaxb-annotations
on your classpath.
There are a couple solves for this:
jackson-module-jaxb-annotations
module, then you can find whatever is putting that on your runtime classpath and exclude it.jackson-module-jaxb-annotations
, then you'll need to ensure its dependencies are on your runtime classpath.Alternatively, you can tell logstash-logback-encoder to not configure jackson to find and register modules dynamically (as mentioned here), but then you'll need to register any modules that you do need explicitly.
Describe the bug I have to add
to avoid
To Reproduce Steps to reproduce the behavior:
7.3
to7.4
and switched to Spring Boot3.2.2
Expected behavior A clear and concise description of what you expected to happen.
Additional context Add any other context about the problem here.
From my lockfile