eclipse-vertx/vert.x · error · DecodeException
Mapping ${toValueType.getName()} is not available without J
Error message
Mapping ${toValueType.getName()} is not available without Jackson Databind on the classpath What it means
JacksonCodec's non-Databind variant cannot map JSON values onto arbitrary Java classes; it only produces basic JSON types (Map, List, String, Number, Boolean, null). Mapping to a user class requires Jackson Databind on the classpath, so calling fromValue(Object, Class) without it always throws this DecodeException.
Source
Thrown at vertx-core/src/main/java/io/vertx/core/json/jackson/JacksonCodec.java:147
@Override
public <T> T fromBuffer(Buffer json, Class<T> clazz) throws DecodeException {
return fromParser(createParser(json), clazz);
}
@Override
public <T> T fromStream(InputStream in, Class<T> clazz) throws DecodeException {
try {
JsonParser parser = factory.createParser(in);
parser.disable(JsonParser.Feature.AUTO_CLOSE_SOURCE);
return fromParser(parser, clazz);
} catch (IOException e) {
throw new DecodeException("Failed to decode:" + e.getMessage(), e);
}
}
@Override
public <T> T fromValue(Object json, Class<T> toValueType) {
throw new DecodeException("Mapping " + toValueType.getName() + " is not available without Jackson Databind on the classpath");
}
@Override
public String toString(Object object, boolean pretty) throws EncodeException {
BufferRecycler br = factory._getBufferRecycler();
try (SegmentedStringWriter sw = new SegmentedStringWriter(br)) {
JsonGenerator generator = createGenerator(sw, pretty);
encodeJson(object, generator);
generator.close();
return sw.getAndClear();
} catch (IOException e) {
throw new EncodeException(e.getMessage(), e);
} finally {
br.releaseToPool();
}
}
@OverrideView on GitHub (pinned to fb308bd8c3)
Solutions
- Add io.vertx:vertx-codec-jackson (or jackson-databind) to the classpath
- Use fromValue(json, Map.class) or parse to Map/List instead of a POJO
- Manually map the resulting Map<String,Object> onto your class
- Verify no dependency exclusion/shading removed jackson-databind
Example fix
// before MyConfig cfg = JacksonCodec.fromValue(json, MyConfig.class); // no databind // after Map<String, Object> map = JacksonCodec.fromValue(json, Map.class); // or add dependency: io.vertx:vertx-codec-jackson with jackson-databind
Defensive patterns
Strategy: fallback
Validate before calling
// Java
static boolean databindAvailable() {
try {
Class.forName("com.fasterxml.jackson.databind.ObjectMapper");
return true;
} catch (ClassNotFoundException e) { return false;
}
} Type guard
static boolean canMapPojo(Class<?> target) {
return databindAvailable() && !Map.class.isAssignableFrom(target) && !List.class.isAssignableFrom(target);
} Try / catch
try {
return JacksonCodec.fromValue(json, MyConfig.class);
} catch (DecodeException e) {
if (e.getMessage().contains("not available without Jackson Databind")) {
return manualMap(JacksonCodec.fromValue(json, Map.class)); // fallback
}
throw e;
} Prevention
- Add jackson-databind (or vertx-codec-jackson) when POJO mapping is needed
- Add a classpath smoke test at startup for ObjectMapper
- Avoid shade/exclude rules that silently drop jackson-databind
- Fall back to Map/List decoding in environments without databind
When it happens
Trigger: Calling JacksonCodec.fromValue(json, SomeClass.class) (or Json.decodeValue targeting a POJO) while jackson-databind is absent from the classpath.
Common situations: Using vertx-core without the jackson-databind dependency and trying to decode JSON into a POJO; a build change (shade/exclude) dropped databind; using the wrong codec class in a custom SPI after removing Databind.
Understand the failure class
Background: "X is not installed. Please install it with pip install Y": missing optional dependency errors — ImportError/ValueError raised when a library's optional extra was never installed — this error's family across 22 libraries.
Related errors
- Failed to decode:${e.getMessage()}
- Failed to decode:
- Unexpected trailing token
- Expecting the current parser token to be the start of an obj
- Expecting the current parser token to be the start of an arr
AI-assisted analysis of eclipse-vertx/vert.x@fb308bd8c3 (2026-09-06).
Data as JSON: /api/errors/6b76eb1d6f479832.
Report an issue: GitHub.