I'm trying to upgrade to latest version of spring boot (just released) and while the program compiles correctly it does not run anymore giving a class not found error:
Caused by: java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlElement at com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector.
(JaxbAnnotationIntrospector.java:137) ~[jackson-module-jaxb-annotations-2.15.3.jar:2.15.3]
I'm using OpenJDK 21
I checked carefully all the release notes and I was not able to find anything related to that problem and the changes needed to correct the dependency problem: did I overlooked something?
Comment From: wilkinsona
You appear to be using the wrong Jackson module. You need jackson-module-jakarta-xmlbind-annotations rather than jackson-module-jaxb-annotations that you appear to be using. This has been the case since Jackson 2.13 when the jakarta module was introduced so I'm not sure why it would only come to light when upgrading from Spring Boot 3.1 to 3.2.
Can you share a minimal reproducer that works with 3.1 but fails when upgraded to 3.2?
Comment From: Polve
For the moment it's too complex to give a minimal reproduction case, but in my pom.xml I have no direct reference to jackson because it gets pulled in (I suppose) by some boot modules.
I can share my spring boot dependencies:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.retry</groupId>
<artifactId>spring-retry</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-messaging</artifactId>
</dependency>
Comment From: wilkinsona
because it gets pulled in (I suppose) by some boot modules
Rather than supposing, please use mvn dependency:tree to determine the exact source of the dependency. You can then exclude it and replace it with jackson-module-jakarta-xmlbind-annotations.
Comment From: Polve
I'm sorry I didn't know how to build dependency tree, thanks :-P
So the problem seems to be that the library is pulled in by another dependency: org.glassfish.jersey.media:jersey-media-json-jackson:jar:3.1.3:compile
I will try to exclude it and replace with the one you mentioned.
Thanks