flowable/flowable-engine · error · FlowableException

Could not serialize event to json string for ${eventInstance

Error message

Could not serialize event to json string for ${eventInstance}

What it means

After building the ObjectNode from all payload instances, EventPayloadToJsonStringSerializer serializes it with objectMapper.writeValueAsString. If Jackson fails to write the tree (a JacksonException), the serializer wraps it in a FlowableException including the eventInstance. This indicates a Jackson-level serialization failure, usually an invalid node state or a misconfigured ObjectMapper.

Source

Thrown at modules/flowable-event-registry/src/main/java/org/flowable/eventregistry/impl/serialization/EventPayloadToJsonStringSerializer.java:144

                        }
                        objectNode.set(payloadInstance.getDefinitionName(), jsonNode);
                    }  else {
                        throw new FlowableIllegalArgumentException("Cannot convert event payload " + jsonValue + " to type 'json'");
                    }

                } else {
                    throw new FlowableIllegalArgumentException("Unsupported event payload instance type: " + definitionType);
                }

            } else {
                objectNode.putNull(payloadInstance.getDefinitionName());
            }
        }

        try {
            return objectMapper.writeValueAsString(objectNode);
        } catch (JacksonException e) {
            throw new FlowableException("Could not serialize event to json string for " + eventInstance, e);
        }
    }

}

View on GitHub (pinned to d6d39ce1c6)

Solutions

  1. Inspect the wrapped JacksonException cause for the real reason Jackson failed to write the tree.
  2. Ensure the values placed into the ObjectNode are standard Jackson JsonNode types created via the same ObjectMapper.
  3. Verify Jackson (jackson-databind) version compatibility with your Flowable version.
  4. Check the ObjectMapper configuration used by the serializer for incompatible serialization features/modules.

Example fix

// before
objectNode.setPOJO("field", new UnsupportedPojo());

// after
objectNode.set("field", objectMapper.valueToTree(new UnsupportedPojo()));
Defensive patterns

Strategy: try-catch

Validate before calling

try {
    objectMapper.writeValueAsBytes(objectNode);
} catch (JacksonException e) {
    throw new IllegalStateException("Event tree not serializable: " + e.getMessage(), e);
}
// writable tree, safe to call serializer.serialize(eventInstance)

Try / catch

try {
    String json = serializer.serialize(eventInstance);
} catch (FlowableException e) {
    logger.error("JSON serialization failed for event: " + eventInstance, e.getCause());
    throw e;
}

Prevention

When it happens

Trigger: Calling serialize(eventInstance) where the constructed ObjectNode contains a node Jackson cannot write, or objectMapper.writeValueAsString throws (e.g. broken objectNode state, custom JsonNode extensions, or an ObjectMapper configured with features that fail during write).

Common situations: Custom/shared ObjectMapper instances with incompatible modules or serialization features; Jackson version mismatches between Flowable and the application; values injected into ObjectNode via set() with exotic JsonNode subtypes.

Understand the failure class

Background: "JSON serialization failed", "not JSON serializable", "Failed to serialize": why JSON marshaling errors happen and how to fix them — this error's family across 46 libraries.

Related errors


AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11). Data as JSON: /api/errors/2a2c3772c7c5d995. Report an issue: GitHub.