flowable/flowable-engine · error · FlowableException

couldn't read input stream

Error message

couldn't read input stream ${inputStreamName}

What it means

IoUtil.readInputStream copies an InputStream into a byte array and wraps any exception during reading into FlowableException with the stream's name, keeping the cause. The name parameter is purely for diagnostics.

Solutions

  1. Check the cause of the FlowableException for the underlying IO problem
  2. Ensure the stream is open and not previously consumed before passing it to readInputStream
  3. Verify the resource actually exists and is fully accessible (correct classpath/URL)
  4. Increase robustness by re-opening the resource from a stable source instead of reusing streams

Example fix

// before
InputStream is = getClass().getResourceAsStream(path);
is.read(); // consumed earlier
byte[] bytes = IoUtil.readInputStream(is, path);
// after
InputStream is = getClass().getResourceAsStream(path);
byte[] bytes = IoUtil.readInputStream(is, path); // stream used exactly once
Defensive patterns

Strategy: try-catch

Validate before calling

InputStream in = loader.getResourceAsStream(name);
if (in == null) throw new IllegalStateException("Resource not on classpath: " + name);

Try / catch

try {
    byte[] bytes = IoUtil.readInputStream(in, name);
} catch (FlowableException e) {
    logger.error("Failed reading stream {}: {}", name, e.getCause(), e.getCause());
}

Prevention

When it happens

Trigger: Reading a deployment resource or classpath stream that is closed, truncated, or whose underlying source fails mid-read (network stream drop, corrupted resource, closed auto-managed stream).

Common situations: Loading BPMN/dmn resources from a jar/URL where the stream was already consumed; temporary file deleted while reading; remote stream interrupted.

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

Appendix: source

Thrown at modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/util/IoUtil.java:45

/**
 * @author Tom Baeyens
 * @author Frederik Heremans
 * @author Joram Barrez
 */
public class IoUtil {

    public static byte[] readInputStream(InputStream inputStream, String inputStreamName) {
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        byte[] buffer = new byte[16 * 1024];
        try {
            int bytesRead = inputStream.read(buffer);
            while (bytesRead != -1) {
                outputStream.write(buffer, 0, bytesRead);
                bytesRead = inputStream.read(buffer);
            }
        } catch (Exception e) {
            throw new FlowableException("couldn't read input stream " + inputStreamName, e);
        }
        return outputStream.toByteArray();
    }

    public static String readFileAsString(String filePath) {
        byte[] buffer = new byte[(int) getFile(filePath).length()];
        BufferedInputStream inputStream = null;
        try {
            inputStream = new BufferedInputStream(new FileInputStream(getFile(filePath)));
            inputStream.read(buffer);
        } catch (Exception e) {
            throw new FlowableException("Couldn't read file " + filePath + ": " + e.getMessage());
        } finally {
            IoUtil.closeSilently(inputStream);
        }
        return new String(buffer);
    }

View on GitHub (pinned to d6d39ce1c6)