flowable/flowable-engine · error · FlowableException

could not get byte array from resource '${resourceName}'

Error message

could not get byte array from resource '${resourceName}'

What it means

CmmnDeploymentBuilderImpl.addInputStream throws FlowableException with "could not get byte array from resource '<resourceName>'" when IoUtil.readInputStream fails while reading the provided stream. The original exception is preserved as the cause; this usually means the stream is unreadable, already closed, or I/O fails mid-read.

Source

Thrown at modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/repository/CmmnDeploymentBuilderImpl.java:59

    public CmmnDeploymentBuilderImpl() {
        CmmnEngineConfiguration cmmnEngineConfiguration = CommandContextUtil.getCmmnEngineConfiguration();
        this.repositoryService = (CmmnRepositoryServiceImpl) cmmnEngineConfiguration.getCmmnRepositoryService();
        this.deployment = cmmnEngineConfiguration.getCmmnDeploymentEntityManager().create();
        this.resourceEntityManager = cmmnEngineConfiguration.getCmmnResourceEntityManager();
    }

    @Override
    public CmmnDeploymentBuilder addInputStream(String resourceName, InputStream inputStream) {
        if (inputStream == null) {
            throw new FlowableException("inputStream for resource '" + resourceName + "' is null");
        }

        byte[] bytes = null;
        try {
            bytes = IoUtil.readInputStream(inputStream, resourceName);
        } catch (Exception e) {
            throw new FlowableException("could not get byte array from resource '" + resourceName + "'", e);
        }

        if (bytes == null) {
            throw new FlowableException("byte array for resource '" + resourceName + "' is null");
        }

        CmmnResourceEntity resource = resourceEntityManager.create();
        resource.setName(resourceName);
        resource.setBytes(bytes);
        deployment.addResource(resource);
        return this;
    }

    @Override
    public CmmnDeploymentBuilder addClasspathResource(String resource) {
        try (final InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(resource)) {
            if (inputStream == null) {
                throw new FlowableException("resource '" + resource + "' not found");

View on GitHub (pinned to d6d39ce1c6)

Solutions

  1. Ensure a fresh, open InputStream is passed for each resource — never reuse a consumed or closed stream.
  2. Inspect the wrapped cause (e.getCause()) for the real I/O error and fix that (file permissions, missing file, network).
  3. Read the bytes yourself first (verify length > 0) and then hand a ByteArrayInputStream to addInputStream if you need controlled behavior.

Example fix

// before
InputStream is = Files.newInputStream(path);
is.close();
builder.addInputStream(name, is); // read fails: stream closed

// after
byte[] bytes = Files.readAllBytes(path);
builder.addInputStream(name, new ByteArrayInputStream(bytes));
Defensive patterns

Strategy: try-catch

Validate before calling

byte[] bytes = Files.readAllBytes(path); // fails early if unreadable
builder.addInputStream(name, new ByteArrayInputStream(bytes));

Try / catch

try {
    builder.addInputStream(name, is);
} catch (FlowableException e) {
    if (e.getCause() == null || !e.getMessage().contains("could not get byte array")) throw e;
    logger.error("failed reading resource " + name, e.getCause());
    throw new DeploymentException("unreadable resource: " + name, e.getCause());
}

Prevention

When it happens

Trigger: Passing an InputStream that was already consumed/closed, a stream backed by a deleted file, or any stream whose read() throws IOException during deployment resource registration.

Common situations: Reusing a stream that was read earlier in the same deployment; try-with-resources closing the stream before the builder reads it; network/socket-backed streams interrupted mid-read.

Understand the failure class

Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.

Related errors


AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11). Data as JSON: /api/errors/b70e0e6349402e27. Report an issue: GitHub.