eclipse-vertx / eclipse-vertx/vert.x

Jackson 3 support does not work

Closed
#6,362 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Java
Stars
14.7k
Forks
2.1k
Avg merge
2d 7h
Merged PRs (30d)
28

Description

### Version

5.1.6

### Context

Hi,

In the 5.1 release notes, [it's claimed that](https://vertx.io/blog/whats-new-in-vert-x-5-1/#jackson-3):

> Vert.x still depends on Jackson 2 (2.21.x LTS) by default. However, Vert.x 5.1 adds support for Jackson 3 (3.1.x): **when Jackson 2 is not present on the class or module path and the Java version is 21 or greater, Vert.x automatically uses Jackson 3.**

However, this does not seem to be true: on Java 25, when Jackson 2 is not present and Jackson 3 is present on the classpath, Jackson 3 is not used and `io.vertx.core.json.DecodeException` is thrown.

The issue can be reproduced with the following minimal setup:

```java
import io.vertx.core.json.JsonObject;

void main() {
var pojo = new Pojo("test");
// io.vertx.core.json.DecodeException: Mapping java.util.Map is not available without Jackson Databind on the classpath
JsonObject obj = JsonObject.mapFrom(pojo);
IO.println(obj);
}

private record Pojo(String test) { }
```

**build.gradle.kts**:
```kotlin
plugins {
id("java")
}

repositories {
mavenCentral()
}

java {
toolchain {
languageVersion = JavaLanguageVersion.of(25)
}
}

dependencies {
implementation("tools.jackson.core:jackson-databind:3.2.2")
implementation("io.vertx:vertx-core:5.1.8")
}
```

**Output**:
```
Exception in thread "main" io.vertx.core.json.DecodeException: Mapping java.util.Map is not available without Jackson Databind on the classpath
at io.vertx.core.json.jackson.JacksonCodec.fromValue(JacksonCodec.java:135)
at io.vertx.core.json.JsonObject.mapFrom(JsonObject.java:412)
at Main.main(Main.java:5)
```

**Full reproducer**: https://github.com/dmitrysulman/vertx-jackson3-bug

Thanks.

### Steps to reproduce

_No response_

### Do you have a reproducer?

https://github.com/dmitrysulman/vertx-jackson3-bug

Contributor guide

Open the contributing guide

Research direction

Start with JsonObject.mapFrom and the JacksonCodec.fromValue stack-trace entry in the reproducer, using Java 25 with the listed Vert.x and Jackson 3 dependencies. Confirm why Jackson 3 is not selected when Jackson 2 is absent, then verify that the reproducer maps the record successfully without DecodeException.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.