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

  1. Null-check the byte array before calling addBytes
  2. Fix the upstream byte-producing code to return empty array or throw a clear error
  3. 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

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


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)