{"record":{"id":"cf9a56cbee511fd1","repo":"flowable/flowable-engine","slug":"error-while-generating-process-image","errorCode":null,"errorMessage":"Error while generating process image","messagePattern":"Error while generating process image","errorType":"exception","errorClass":"FlowableImageException","httpStatus":null,"severity":"error","filePath":"modules/flowable-image-generator/src/main/java/org/flowable/image/impl/DefaultProcessDiagramCanvas.java","lineNumber":270,"sourceCode":"            LOGGER.warn(\"Could not load image for process diagram creation: {}\", e.getMessage());\n        }\n    }\n\n    /**\n     * Generates an image of what currently is drawn on the canvas.\n     * \n     * Throws an {@link FlowableImageException} when {@link #close()} is already called.\n     */\n    public InputStream generateImage(String imageType) {\n        if (closed) {\n            throw new FlowableImageException(\"ProcessDiagramGenerator already closed\");\n        }\n\n        try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {\n            ImageIO.write(processDiagram, imageType, out);\n            return new ByteArrayInputStream(out.toByteArray());\n        } catch (IOException e) {\n            throw new FlowableImageException(\"Error while generating process image\", e);\n        }\n    }\n\n    /**\n     * Generates an image of what currently is drawn on the canvas.\n     * \n     * Throws an {@link FlowableImageException} when {@link #close()} is already called.\n     */\n    public BufferedImage generateBufferedImage(String imageType) {\n        if (closed) {\n            throw new FlowableImageException(\"ProcessDiagramGenerator already closed\");\n        }\n\n        // Try to remove white space\n        minX = (minX <= 5) ? 5 : minX;\n        minY = (minY <= 5) ? 5 : minY;\n        BufferedImage imageToSerialize = processDiagram;\n        imageToSerialize = processDiagram.getSubimage(minX - 5, minY - 5, canvasWidth - minX + 5, canvasHeight - minY + 5);","sourceCodeStart":252,"sourceCodeEnd":288,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-image-generator/src/main/java/org/flowable/image/impl/DefaultProcessDiagramCanvas.java#L252-L288","documentation":"DefaultProcessDiagramCanvas.generateImage() writes the rendered BufferedImage via ImageIO.write to a ByteArrayOutputStream. If the underlying ImageIO write fails with an IOException (unsupported image type string, missing image writer, IO problem), it is wrapped in FlowableImageException with this message.","triggerScenarios":"Passing an imageType string with no registered ImageIO writer (e.g. a typo like \"jpeg \" or a type unsupported on the JRE); an IOException inside ImageIO.write while serializing the diagram.","commonSituations":"Using an exotic image format not supported by the headless JVM; running in a stripped-down container JDK without the standard image codecs; dynamically built image type strings containing errors.","solutions":["Verify the imageType is one of the formats supported by ImageIO (e.g. \"png\", \"gif\", \"jpg\") on the target JVM","Inspect the wrapped cause exception for the real IOException","Ensure the JDK/JRE includes standard image writers (not a minimal/headless-distilled JRE without codecs)","Call ImageIO.getWriterFormatNames() at startup to confirm supported formats"],"exampleFix":"// before\nInputStream is = canvas.generateImage(\"jpeg2000\"); // no writer registered\n// after\nInputStream is = canvas.generateImage(\"png\");","handlingStrategy":"try-catch","validationCode":"boolean supported = java.util.Arrays.asList(javax.imageio.ImageIO.getWriterFormatNames())\n        .contains(imageType.toLowerCase());\nif (!supported) throw new IllegalArgumentException(\"Unsupported image type: \" + imageType);","typeGuard":null,"tryCatchPattern":"try {\n    InputStream is = canvas.generateImage(imageType);\n} catch (FlowableImageException e) {\n    log.error(\"Image generation failed for type \" + imageType, e.getCause());\n}","preventionTips":["Use only PNG/GIF/JPEG image types verified with ImageIO.getWriterFormatNames()","Never build the imageType string dynamically from unvalidated input","Verify the runtime JRE includes standard image writers","Log the cause chain, not just the wrapper message"],"tags":["image-generation","io","flowable","imageio"],"backgroundTag":"file-write-failed","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-18T11:17:12.947Z"}