flowable/flowable-engine · error · XMLException
Error writing CMMN XML
Error message
Error writing CMMN XML
What it means
convertToXML wraps any exception raised while serializing a CmmnModel to XML bytes (including StAX writing and schema validation failures) into XMLException("Error writing CMMN XML"). It indicates the model could not be serialized, often because it is incomplete or violates the CMMN schema.
Source
Thrown at modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/CmmnXmlConverter.java:344
}
CmmnDIExport.writeCmmnDI(model, xtw);
// end definitions root element
xtw.writeEndElement();
xtw.writeEndDocument();
xtw.flush();
outputStream.close();
xtw.close();
return outputStream.toByteArray();
} catch (Exception e) {
LOGGER.error("Error writing CMMN XML", e);
throw new XMLException("Error writing CMMN XML", e);
}
}
protected void processCmmnElements(ConversionHelper conversionHelper) {
CmmnModel cmmnModel = conversionHelper.getCmmnModel();
for (Case caze : cmmnModel.getCases()) {
processPlanFragment(cmmnModel, caze.getPlanModel());
}
// CMMN doesn't mandate ids on many elements ... adding generated ids
// to those elements as this makes the logic much easier
ensureIds(conversionHelper.getPlanFragments(), "planFragment_");
ensureIds(conversionHelper.getStages(), "stage_");
ensureIds(conversionHelper.getEntryCriteria(), "entryCriterion_");
ensureIds(conversionHelper.getExitCriteria(), "exitCriterion_");
ensureIds(conversionHelper.getSentries(), "sentry_");
ensureIds(conversionHelper.getSentryOnParts(), "onPart_");
ensureIds(conversionHelper.getSentryIfParts(), "ifPart_");View on GitHub (pinned to d6d39ce1c6)
Solutions
- Read the chained cause to see which element/attribute failed serialization or validation
- Validate the CmmnModel programmatically before conversion (required ids/refs non-null, definitionRef/sentryRef resolvable)
- Use convertToCmmnModel round-tripping to sanity-check models built by code
- Pass a valid charset name as the encoding argument
Example fix
// before CmmnModel model = new CmmnModel(); // no cases/ids set converter.convertToXML(model); // after CmmnModel model = buildCompleteModel(); // set ids, cases, plan items byte[] xml = converter.convertToXML(model); // validates against XSD
Defensive patterns
Strategy: try-catch
Validate before calling
if (model.getCases() == null || model.getCases().isEmpty())
throw new IllegalStateException("CmmnModel has no cases; nothing valid to serialize"); Try / catch
try {
byte[] xml = converter.convertToXML(model);
} catch (XMLException e) {
log.error("CMMN serialization failed", e.getCause());
throw new DeploymentException("Model cannot be written as CMMN XML", e);
} Prevention
- Set all required model fields (ids, plan item definitions, refs) before conversion
- Round-trip models (convertToXML then convertToCmmnModel) in tests to catch incomplete models
- Pass StandardCharsets.UTF_8.name() as encoding
When it happens
Trigger: Calling CmmnXmlConverter.convertToXML(model) or convertToXML(model, encoding) with a model containing null/invalid required elements, an unsupported encoding name, or content failing XSD validation during output.
Common situations: Programmatically constructed CmmnModel missing required fields (e.g. null case/stage ids), models imported from incompatible sources, or deploying a model that was never validated.
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
- Error writing BPMN XML
- Error reading XML
- Error processing CMMN XML document
- Error writing DMN XML
- The bpmn 2.0 xml is not properly encoded
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/54b5fb93ffcdecf3.
Report an issue: GitHub.