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
- Inspect the wrapped cause (e.getCause()) for the real I/O problem and fix it.
- Open a fresh InputStream for each deployment; never reuse an already-consumed stream.
- Ensure the backing file/resource is readable and not deleted/locked at deploy time.
- 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
- Always log e.getCause() — the wrapped IOException carries the real diagnosis.
- Never reuse an already-consumed InputStream; open a new one per deployment.
- Check file readability/existence before building the stream.
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
- Failed to read resource ${resource}
- Could not find a resource with id '<resourceName>' in deploy
- <e.getMessage()>
- Could not find an app deployment with id '<deploymentId>
- no apps deployed with key = '' and version = ''
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/e897ac9b11918d20.
Report an issue: GitHub.