flowable/flowable-engine · error · FlowableException
bytes array is null
Error message
bytes array is null
What it means
FlowableException thrown by CmmnDeploymentBuilderImpl.addBytes when the bytes parameter is null. The resource entity needs a byte array to store, so null is rejected immediately. Fail-fast validation for programmatic deployment building.
Solutions
- Ensure the byte[] is non-null and populated before calling addBytes
- Check the code producing the byte array for silent null returns on failure
- Initialize or load the bytes explicitly and fail early with your own message
Example fix
// before
byte[] modelBytes = toBytes(model); // may return null
builder.addBytes("model.cmmn.xml", modelBytes);
// after
byte[] modelBytes = toBytes(model);
Objects.requireNonNull(modelBytes, "model bytes must not be null");
builder.addBytes("model.cmmn.xml", modelBytes); Defensive patterns
Strategy: validation
Validate before calling
if (bytes == null || bytes.length == 0) { throw new IllegalArgumentException("Resource bytes must be non-empty: " + resourceName); } Type guard
static boolean hasContent(byte[] b) { return b != null && b.length > 0; } Try / catch
try {
builder.addBytes(resourceName, bytes);
} catch (FlowableException e) {
if ("bytes array is null".equals(e.getMessage())) {
throw new IllegalArgumentException("Missing byte content for " + resourceName, e);
}
throw e;
} Prevention
- Require serialization helpers to throw on failure rather than return null
- Use Optional<byte[]> or explicit exceptions in byte-producing code
- Check byte[] length, not just null, to also catch empty content
- Unit-test the bytes-producing step independently of Flowable
When it happens
Trigger: Calling addBytes(resourceName, null) or passing a byte[] variable produced by a read/conversion step that returned null (failed serialization, missing file conversion, unassigned field).
Common situations: Converting a model to bytes via code that silently returns null on failure, loading binary resources from storage that returned null, test fixtures with uninitialized arrays.
Related errors
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/264a1cec554de070.
Report an issue: GitHub.
Appendix: source
Thrown at modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/repository/CmmnDeploymentBuilderImpl.java:102
}
@Override
public CmmnDeploymentBuilder addString(String resourceName, String text) {
if (text == null) {
throw new FlowableException("text is null");
}
CmmnResourceEntity resource = resourceEntityManager.create();
resource.setName(resourceName);
resource.setBytes(text.getBytes(StandardCharsets.UTF_8));
deployment.addResource(resource);
return this;
}
@Override
public CmmnDeploymentBuilder addBytes(String resourceName, byte[] bytes) {
if (bytes == null) {
throw new FlowableException("bytes array is null");
}
CmmnResourceEntity resource = resourceEntityManager.create();
resource.setName(resourceName);
resource.setBytes(bytes);
deployment.addResource(resource);
return this;
}
@Override
public CmmnDeploymentBuilder addZipInputStream(ZipInputStream zipInputStream) {
try {
ZipEntry entry = zipInputStream.getNextEntry();
while (entry != null) {
if (!entry.isDirectory()) {
String entryName = entry.getName();
byte[] bytes = IoUtil.readInputStream(zipInputStream, entryName);
CmmnResourceEntity resource = resourceEntityManager.create();View on GitHub (pinned to d6d39ce1c6)