Skip to content

Use Jackson 3 with Jersey - #51935

Closed
rene-schakmann wants to merge 1 commit into
spring-projects:mainfrom
rene-schakmann:gh-51931
Closed

rene-schakmann wants to merge 1 commit into
spring-projects:mainfrom
rene-schakmann:gh-51931

Conversation

@rene-schakmann

Copy link
Copy Markdown

Jersey 4.0.3 added jersey-media-json-jackson3. This PR upgrades to Jersey 4.0.3 and switches spring-boot-jersey and spring-boot-starter-jersey from Jackson 2 to Jackson 3.

Closes #51931

Changes

  • Upgrade Jersey to 4.0.3. The upgrade is needed for jersey-media-json-jackson3, so it isn't a plain version bump.
  • spring-boot-jersey now depends on jersey-media-json-jackson3 instead of jersey-media-json-jackson. spring-boot-starter-jersey now depends on spring-boot-jackson instead of spring-boot-jackson2.
  • JerseyAutoConfiguration registers Jersey's Jackson 3 JacksonFeature and a ContextResolver<JsonMapper> when there's a single JsonMapper bean. Jersey's Jackson 3 provider looks up ContextResolver<JsonMapper>, not ContextResolver<ObjectMapper>.
  • JerseyWebEndpointManagementContextConfiguration registers a ContextResolver<JsonMapper> backed by EndpointJsonMapper for OperationResponseBody types. This mirrors the existing EndpointJackson2ObjectMapper support.
  • No JAXB customizer is added for Jackson 3. The auto-configured JsonMapper already registers JakartaXmlBindAnnotationModule through findAndAddModules, and an explicit customizer would add a second introspector. The @XmlTransient assertion in JerseyAutoConfigurationJsonMapperProviderTests covers this end to end.
  • The Jackson 2 support is kept. It still applies if you use jersey-media-json-jackson in place of jersey-media-json-jackson3. Both Jersey modules register a feature under the same jersey.config.jsonFeature name (JacksonFeature), so they shouldn't be on the classpath together. For that reason the Jackson 2 module is now compileOnly. Its tests moved to JerseyAutoConfigurationJackson2Tests, which uses @ClassPathExclusions/@ClassPathOverrides.
  • Tests, the Jersey smoke tests and the actuator integration tests now use Jackson 3. The health response assertion now matches Jackson 3's alphabetical property order, as the Spring MVC and WebFlux smoke tests already do. The isolated mapper false test now follows the WebFlux equivalent.
  • Docs: removed the note that Jersey requires Jackson 2 for actuator.

Notes for reviewers

  • Jersey 4.0.3 is built against Jackson 3.2.3, while Boot manages Jackson 3.1.6. All Jersey tests pass with 3.1.6, including those that start a real server.
  • The Jackson 2 test hard-codes jersey-media-json-jackson:4.0.3 in @ClassPathOverrides, so it will need updating on Jersey upgrades. I'm happy to change this or drop the Jackson 2 support if you'd rather remove it.

Verification

./gradlew :module:spring-boot-jersey:check \
  :starter:spring-boot-starter-jersey:check \
  :smoke-test:spring-boot-smoke-test-jersey:check \
  :smoke-test:spring-boot-smoke-test-secure-jersey:check \
  :integration-test:spring-boot-actuator-integration-tests:check

All pass with 0 failures: 78 tests in spring-boot-jersey, 24 + 50 in the Jersey smoke tests, and 361 in the actuator integration tests.

🤖 Generated with Claude Code

Jersey 4.0.3 provides jersey-media-json-jackson3. This commit upgrades
to Jersey 4.0.3 and switches spring-boot-jersey and
spring-boot-starter-jersey from Jackson 2 to Jackson 3.

When a single JsonMapper bean is available, JerseyAutoConfiguration
now registers Jersey's Jackson 3 JacksonFeature along with a
ContextResolver for the JsonMapper. Actuator endpoints use the
EndpointJsonMapper for OperationResponseBody instances. JAXB
annotation support is provided by the auto-configured JsonMapper's
module discovery so no additional customization is required.

The existing Jackson 2 support is retained and continues to apply
when jersey-media-json-jackson is used in place of
jersey-media-json-jackson3.

See spring-projectsgh-51931

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: rene.schakmann <rene.schakmann@reetgroup.com>
@wilkinsona

Copy link
Copy Markdown
Member

Thanks for the PR, but #51936 appears to be more complete.

Generated with Claude Code

Unfortunately, I don't think this is a good way to contribute. If we wanted a Claude-generated contribution, we could do so ourselves. By all means use an LLM if you wish, but the resulting code, commit message, and PR description should be reviewed and edited such that it's as if it had been written by hand.

@wilkinsona wilkinsona closed this Oct 3, 2026
@wilkinsona wilkinsona added status: declined A suggestion or change that we don't feel we should currently apply and removed status: waiting-for-triage An issue we've not yet triaged labels Oct 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: declined A suggestion or change that we don't feel we should currently apply

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Switch spring-boot-starter-jersey to use Jackson 3 rather than Jackson 2

3 participants