Activiti/Activiti · error · ActivitiIllegalArgumentException
bytes is null
Error message
bytes is null
What it means
Parameter guard in DeploymentBuilderImpl.addBytes: the byte content of the deployment resource is required, and null bytes would create an empty resource. Thrown when addBytes is called with a null byte array.
Solutions
- Null-check the byte array before calling addBytes
- Fix the upstream byte-producing code to return empty array or throw a clear error
- Use addInputStream/addString/addClasspathResource if that suits the source better
Example fix
// before
builder.addBytes("res.bin", produceBytes()); // may be null
// after
byte[] b = produceBytes();
if (b != null) { builder.addBytes("res.bin", b); } Defensive patterns
Strategy: validation
Validate before calling
if (bytes == null) throw new IllegalArgumentException("bytes must not be null"); Type guard
boolean hasBytes(byte[] b) { return b != null; } Try / catch
try { builder.addBytes(name, bytes); } catch (org.activiti.engine.ActivitiIllegalArgumentException e) { if ("bytes is null".equals(e.getMessage())) { /* fix byte source */ } else throw e; } Prevention
- Null-check output of byte-producing helpers before use
- Prefer throwing early at the byte source instead of returning null
- Use empty arrays rather than null to represent 'no content'
When it happens
Trigger: builder.addBytes(name, null), typically when bytes come from a failed read, a null-returning helper, or an uninitialized field.
Common situations: Files.readAllBytes on a nonexistent file path guarded elsewhere; generated byte content (e.g. model XML) that failed; null returned from a cache or transform utility.
Related errors
- inputStream for resource
- text is null
- Booleans and null cannot be used in 'greater than' condition
- Booleans and null cannot be used in 'greater than or equal'…
- Booleans and null cannot be used in 'less than' condition
AI-assisted analysis of Activiti/Activiti@56435b1a97 (2026-09-09).
Data as JSON: /api/errors/c474ec6dce648e63.
Report an issue: GitHub.
Appendix: source
Thrown at activiti-core/activiti-engine/src/main/java/org/activiti/engine/impl/repository/DeploymentBuilderImpl.java:163
public DeploymentBuilder addString(String resourceName, String text) {
if (text == null) {
throw new ActivitiIllegalArgumentException("text is null");
}
ResourceEntity resource = resourceEntityManager.create();
resource.setName(resourceName);
try {
resource.setBytes(text.getBytes(DEFAULT_ENCODING));
} catch (UnsupportedEncodingException e) {
throw new ActivitiException("Unable to get process bytes.", e);
}
deployment.addResource(resource);
return this;
}
public DeploymentBuilder addBytes(String resourceName, byte[] bytes) {
if (bytes == null) {
throw new ActivitiIllegalArgumentException("bytes is null");
}
ResourceEntity resource = resourceEntityManager.create();
resource.setName(resourceName);
resource.setBytes(bytes);
deployment.addResource(resource);
return this;
}
public DeploymentBuilder addZipInputStream(ZipInputStream zipInputStream) {
try {
ZipEntry entry = zipInputStream.getNextEntry();
while (entry != null) {
if (!entry.isDirectory()) {
String entryName = entry.getName();
byte[] bytes = IoUtil.readInputStream(zipInputStream, entryName);
ResourceEntity resource = resourceEntityManager.create();
resource.setName(entryName);View on GitHub (pinned to 56435b1a97)