flowable/flowable-engine · error · FlowableException
Error writing form model response
Error message
Error writing form model response
What it means
getFormModelString serializes a FormModelResponse to JSON with Jackson's ObjectMapper. Any exception during serialization (unwritable property, circular reference, custom serializer failure) is wrapped in a FlowableException with this message.
Source
Thrown at modules/flowable-cmmn-rest/src/main/java/org/flowable/cmmn/rest/service/api/CmmnRestResponseFactory.java:257
response.setGraphicalNotationDefined(caseDefinition.hasGraphicalNotation());
response.setStartFormDefined(caseDefinition.hasStartFormKey());
response.setTenantId(caseDefinition.getTenantId());
// Links to other resources
response.setDeploymentId(caseDefinition.getDeploymentId());
response.setDeploymentUrl(urlBuilder.buildUrl(CmmnRestUrls.URL_DEPLOYMENT, caseDefinition.getDeploymentId()));
response.setResource(urlBuilder.buildUrl(CmmnRestUrls.URL_DEPLOYMENT_RESOURCE, caseDefinition.getDeploymentId(), caseDefinition.getResourceName()));
if (caseDefinition.getDiagramResourceName() != null) {
response.setDiagramResource(urlBuilder.buildUrl(CmmnRestUrls.URL_DEPLOYMENT_RESOURCE, caseDefinition.getDeploymentId(), caseDefinition.getDiagramResourceName()));
}
return response;
}
public String getFormModelString(FormModelResponse formModelResponse) {
try {
return objectMapper.writeValueAsString(formModelResponse);
} catch (Exception e) {
throw new FlowableException("Error writing form model response", e);
}
}
public List<RestVariable> createRestVariables(Map<String, Object> variables, String id, int variableType) {
RestUrlBuilder urlBuilder = createUrlBuilder();
List<RestVariable> result = new ArrayList<>(variables.size());
for (Entry<String, Object> pair : variables.entrySet()) {
result.add(createRestVariable(pair.getKey(), pair.getValue(), null, id, variableType, false, urlBuilder));
}
return result;
}
public List<RestVariable> createRestVariables(Map<String, Object> variables, String id, int variableType, RestVariableScope scope) {
RestUrlBuilder urlBuilder = createUrlBuilder();
List<RestVariable> result = new ArrayList<>(variables.size());
View on GitHub (pinned to d6d39ce1c6)
Solutions
- Inspect the wrapped cause to identify which property failed serialization
- Add getters or @JsonIgnore to offending fields in the form model
- Enable/disable appropriate Jackson features on the ObjectMapper (e.g. SerializationFeature.FAIL_ON_EMPTY_BEANS)
- Ensure only standard FormModelResponse implementations are passed to this factory
Example fix
// before
class MyFormModel { private Object selfRef; void init(){ selfRef = this; } }
// after
class MyFormModel { @JsonIgnore private Object selfRef; } Defensive patterns
Strategy: try-catch
Validate before calling
new ObjectMapper().writeValueAsString(formModelResponse); // dry-run serialization check
Try / catch
try {
String json = factory.getFormModelString(formModelResponse);
} catch (FlowableException e) {
logger.error("Form model serialization failed", e.getCause());
} Prevention
- Keep form model classes Jackson-friendly (getters, no cycles, @JsonIgnore on internals)
- Dry-run serialize custom models in tests
- Pin Jackson configuration deliberately (FAIL_ON_EMPTY_BEANS etc.)
When it happens
Trigger: Calling getFormModelString on a FormModelResponse whose properties cannot be serialized by the configured ObjectMapper (e.g. object with no accessible getters, self-referencing structure).
Common situations: Custom form model implementations with non-Jackson-friendly fields;Jackson configuration (FAIL_ON_EMPTY_BEANS) triggered by null/empty beans; version changes in form model classes.
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
- Failed to serialize to a RestVariable instance
- Cannot get variable value for jackson 2
- Failed to parse jase
- An error occurs converting output value as JSon
- Error writing form model response
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/38de3c7df6930810.
Report an issue: GitHub.