apache/seatunnel · error · RuntimeException
Object json deserialization exception.
Error message
Object json deserialization exception.
What it means
JsonUtils.toJsonString(Object) is the single-argument serialization helper. When Jackson fails to write the object as JSON, the exception is wrapped in this RuntimeException with the (slightly misleading) message 'Object json deserialization exception.' even though it is a serialization failure.
Source
Thrown at seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/JsonUtils.java:263
try {
return OBJECT_MAPPER.readValue(json, type);
} catch (Exception e) {
throw new RuntimeException("Json parse object exception.", e);
}
}
/**
* object to json string
*
* @param object object
* @return json string
*/
public static String toJsonString(Object object) {
try {
return OBJECT_MAPPER.writeValueAsString(object);
} catch (Exception e) {
throw new RuntimeException("Object json deserialization exception.", e);
}
}
public static ObjectNode parseObject(String text) {
return parseObject(text.getBytes(StandardCharsets.UTF_8));
}
public static ObjectNode parseObject(byte[] content) {
try {
return (ObjectNode) OBJECT_MAPPER.readTree(content);
} catch (IOException e) {
throw new RuntimeException(
"String json deserialization exception."
+ new String(content, StandardCharsets.UTF_8),
e);
}
}
View on GitHub (pinned to cf67b549a7)
Solutions
- Open the chained cause — despite the message, this is a serialization (write) failure, typically JsonMappingException
- Annotate back-references with @JsonIgnore or use @JsonManagedReference/@JsonBackReference for cycles
- Fix or guard getters that throw for closed resources
- Convert exotic types to simple DTOs before serializing
Example fix
// before
class Task { Task parent; }
JsonUtils.toJsonString(task); // StackOverflowError from recursion
// after
class Task { @JsonIgnore Task parent; }
JsonUtils.toJsonString(task); Defensive patterns
Strategy: try-catch
Try / catch
try {
String json = JsonUtils.toJsonString(obj);
} catch (RuntimeException e) {
log.warn("serialization failed for {}: {}", obj.getClass(), e.getCause());
json = String.valueOf(obj);
} Prevention
- Note the message is misleading: this is a write/serialization failure; always inspect the cause
- Eliminate cyclic references in DTOs
- Keep serialization tests for all persisted/logged objects
When it happens
Trigger: Calling JsonUtils.toJsonString(obj) on cyclic object graphs, objects whose getters throw, or types with no registered serializer.
Common situations: Persisting or logging POJOs before job submission, serializing engine state objects with back-references, passing objects holding closed streams or stale connections.
Understand the failure class
Background: json.Marshal / "failed to marshal" errors in Go: why "unsupported type" happens and how to fix it — this error's family across 22 libraries.
Related errors
- Object to json exception!
- JSON_OPERATION_FAILED
- COMMON_UNSUPPORTED_DATA_TYPE
- failed to serialize event as JSON
- failed to serialize event as JSON
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/fdd402adb3d19570.
Report an issue: GitHub.