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

While reading the provided InputStream into a byte array with IoUtil.readInputStream, an exception occurred; addInputStream() wraps it and rethrows FlowableException('could not get byte array from resource ...') with the original exception as cause. The cause (I/O error, closed stream) is the real diagnostic.

Source

Thrown at modules/flowable-app-engine/src/main/java/org/flowable/app/engine/impl/repository/AppDeploymentBuilderImpl.java:58

    public AppDeploymentBuilderImpl() {
        AppEngineConfiguration appEngineConfiguration = CommandContextUtil.getAppEngineConfiguration();
        this.repositoryService = (AppRepositoryServiceImpl) appEngineConfiguration.getAppRepositoryService();
        this.deployment = appEngineConfiguration.getAppDeploymentEntityManager().create();
        this.resourceEntityManager = appEngineConfiguration.getAppResourceEntityManager();
    }

    @Override
    public AppDeploymentBuilder 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");
        }

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

    @Override
    public AppDeploymentBuilder 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. Inspect the wrapped cause (e.getCause()) for the real I/O problem and fix it.
  2. Open a fresh InputStream for each deployment; never reuse an already-consumed stream.
  3. Ensure the backing file/resource is readable and not deleted/locked at deploy time.
  4. Wrap stream creation and deployment in try-with-resources so streams are open and valid during the read.

Example fix

// before
InputStream in = oldCache.get(resourceName); // already-consumed stream
deploymentBuilder.addInputStream(resourceName, in); // read fails

// after
try (InputStream in = getClass().getClassLoader().getResourceAsStream(resourceName)) {
    deploymentBuilder.addInputStream(resourceName, in);
}
Defensive patterns

Strategy: try-catch

Validate before calling

if (!Files.isReadable(Paths.get(filePath))) { throw new IllegalStateException("Resource not readable: " + filePath); }

Try / catch

try { deploymentBuilder.addInputStream(name, in); } catch (FlowableException e) { log.error("Failed reading resource {} : {}", name, e.getCause(), e); }

Prevention

When it happens

Trigger: Calling addInputStream (directly or via addClasspathResource) with a stream whose backing source is broken or already closed — e.g. a closed FileInputStream, a socket stream that errored, or a stream consumed by a previous read.

Common situations: Reusing an InputStream that was already read; streams from files that were deleted or locked mid-read; interrupted/failed I/O when loading from a network or archive source.

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/e897ac9b11918d20. Report an issue: GitHub.