{"record":{"id":"2a2c3772c7c5d995","repo":"flowable/flowable-engine","slug":"could-not-serialize-event-to-json-string-for-eve","errorCode":null,"errorMessage":"Could not serialize event to json string for ${eventInstance}","messagePattern":"Could not serialize event to json string for (.+?)","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-event-registry/src/main/java/org/flowable/eventregistry/impl/serialization/EventPayloadToJsonStringSerializer.java","lineNumber":144,"sourceCode":"                        }\n                        objectNode.set(payloadInstance.getDefinitionName(), jsonNode);\n                    }  else {\n                        throw new FlowableIllegalArgumentException(\"Cannot convert event payload \" + jsonValue + \" to type 'json'\");\n                    }\n\n                } else {\n                    throw new FlowableIllegalArgumentException(\"Unsupported event payload instance type: \" + definitionType);\n                }\n\n            } else {\n                objectNode.putNull(payloadInstance.getDefinitionName());\n            }\n        }\n\n        try {\n            return objectMapper.writeValueAsString(objectNode);\n        } catch (JacksonException e) {\n            throw new FlowableException(\"Could not serialize event to json string for \" + eventInstance, e);\n        }\n    }\n\n}\n","sourceCodeStart":126,"sourceCodeEnd":149,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-event-registry/src/main/java/org/flowable/eventregistry/impl/serialization/EventPayloadToJsonStringSerializer.java#L126-L149","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Inspect the wrapped JacksonException cause for the real reason Jackson failed to write the tree.","Ensure the values placed into the ObjectNode are standard Jackson JsonNode types created via the same ObjectMapper.","Verify Jackson (jackson-databind) version compatibility with your Flowable version.","Check the ObjectMapper configuration used by the serializer for incompatible serialization features/modules."],"exampleFix":"// before\nobjectNode.setPOJO(\"field\", new UnsupportedPojo());\n\n// after\nobjectNode.set(\"field\", objectMapper.valueToTree(new UnsupportedPojo()));","handlingStrategy":"try-catch","validationCode":"try {\n    objectMapper.writeValueAsBytes(objectNode);\n} catch (JacksonException e) {\n    throw new IllegalStateException(\"Event tree not serializable: \" + e.getMessage(), e);\n}\n// writable tree, safe to call serializer.serialize(eventInstance)","typeGuard":null,"tryCatchPattern":"try {\n    String json = serializer.serialize(eventInstance);\n} catch (FlowableException e) {\n    logger.error(\"JSON serialization failed for event: \" + eventInstance, e.getCause());\n    throw e;\n}","preventionTips":["Keep payload values as standard Jackson JsonNode instances.","Pin a jackson-databind version compatible with your Flowable release.","Test ObjectMapper configuration (modules/features) in unit tests before deploying."],"tags":["flowable","event-registry","json","jackson","serialization-failed"],"backgroundTag":"json-serialization-failed","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}