flowable/flowable-engine · error · FlowableImageException

Error while generating case image

Error message

Error while generating case image

What it means

Thrown by DefaultCaseDiagramCanvas.generateImage when writing the rendered case diagram to the requested image type via ImageIO fails (unsupported/unknown imageType or an encoding error), and re-raised as a FlowableImageException with this wrapper message.

Source

Thrown at modules/flowable-cmmn-image-generator/src/main/java/org/flowable/cmmn/image/impl/DefaultCaseDiagramCanvas.java:229

            LOGGER.warn("Could not load image for case diagram creation: {}", e.getMessage());
        }
    }

    /**
     * Generates an image of what currently is drawn on the canvas.
     *
     * Throws an {@link FlowableImageException} when {@link #close()} is already called.
     */
    public InputStream generateImage(String imageType) {
        if (closed) {
            throw new FlowableImageException("CaseDiagramGenerator already closed");
        }

        try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
            ImageIO.write(caseDiagram, imageType, out);
            return new ByteArrayInputStream(out.toByteArray());
        } catch (IOException e) {
            throw new FlowableImageException("Error while generating case image", e);
        }
    }

    /**
     * Generates an image of what currently is drawn on the canvas.
     *
     * Throws an {@link FlowableImageException} when {@link #close()} is already called.
     */
    public BufferedImage generateBufferedImage(String imageType) {
        if (closed) {
            throw new FlowableImageException("CaseDiagramGenerator already closed");
        }

        // Try to remove white space
        minX = (minX <= 5) ? 5 : minX;
        minY = (minY <= 5) ? 5 : minY;
        BufferedImage imageToSerialize = caseDiagram;
        imageToSerialize = caseDiagram.getSubimage(minX - 5, minY - 5, canvasWidth - minX + 5, canvasHeight - minY + 5);

View on GitHub (pinned to d6d39ce1c6)

Solutions

  1. Log/check the wrapped cause (e.getCause()) to see the real IOException
  2. Use a standard supported imageType such as "png"
  3. Ensure the JVM runs headless-safe (java.awt.headless=true) with an JDK that includes the needed ImageIO writers
  4. Validate any user/config-supplied image type before calling generateImage

Example fix

// before
canvas.generateImage(imageTypeFromConfig);
// after
if (!imageTypeFromConfig.matches("(png|jpeg|jpg|gif)")) imageTypeFromConfig = "png";
canvas.generateImage(imageTypeFromConfig);
Defensive patterns

Strategy: try-catch

Validate before calling

Set<String> supported = Set.of("png","jpeg","jpg","gif");
if (!supported.contains(imageType)) throw new IllegalArgumentException("unsupported imageType: " + imageType);

Try / catch

try {
    return canvas.generateImage("png");
} catch (FlowableImageException e) {
    throw new RuntimeException("Diagram rendering failed: " + e.getCause(), e);
}

Prevention

When it happens

Trigger: generateImage called with an imageType ImageIO has no writer for (e.g. unsupported/misspelled format string), or an underlying I/O failure while writing the BufferedImage to the ByteArrayOutputStream.

Common situations: Passing 'jpg' vs 'jpeg' mismatches or an entirely unknown type from configuration; headless environments missing image codecs; propagating a low-level IOException.

Understand the failure class

Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.

Related errors


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