Activiti/Activiti · error · ActivitiImageException

Error while generating process image

Error message

Error while generating process image

What it means

generateImage() streams the diagram as SVG using a Graphics2D SVG adapter. If the stream operation fails — UnsupportedEncodingException for the hard-coded UTF-8 or an SVGGraphics2DIOException from the SVG library — it is wrapped in this ActivitiImageException.

Solutions

  1. Inspect the wrapped cause (getCause()) to find whether it is encoding or SVG-IO related and address that specific failure
  2. Ensure the JVM supports UTF-8 (standard on all modern JVMs; fix any custom charset provider issues)
  3. Simplify/fix unusual BPMN diagram elements (custom label text, exotic characters) that may break SVG generation
  4. Upgrade Activiti's image generator or the underlying SVG library version

Example fix

// before
InputStream is = generator.generateDiagram(bpmnModel, "png", activityId); // may throw
// after
try {
    InputStream is = generator.generateDiagram(bpmnModel, "png", activityId);
} catch (ActivitiImageException e) {
    logger.error("Diagram generation failed", e.getCause());
    throw e;
}
Defensive patterns

Strategy: try-catch

Try / catch

try {
    InputStream is = canvas.generateImage();
} catch (ActivitiImageException e) {
    if (e.getMessage().equals("Error while generating process image")) {
        Throwable root = deepestCause(e);
        if (root instanceof SVGGraphics2DIOException) {
            // handle SVG encoding failure, e.g. simplify diagram content
        }
    } else { throw e; }
}

Prevention

When it happens

Trigger: Any I/O or SVG-generation failure while writing the SVG (e.g. SVGGraphics2DIOException from invalid drawn content or an underlying stream error), or a JVM lacking the UTF-8 charset name.

Common situations: Diagrams containing shapes/labels that the SVG generator cannot encode; JVM with unusual charset configuration; failures deep in the Batik-based SVGGraphics2D implementation.

Understand the failure class

Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.

Related errors


AI-assisted analysis of Activiti/Activiti@56435b1a97 (2026-09-09). Data as JSON: /api/errors/67af0d4143fa13b9. Report an issue: GitHub.

Appendix: source

Thrown at activiti-core/activiti-image-generator/src/main/java/org/activiti/image/impl/DefaultProcessDiagramCanvas.java:308

    /**
     * Generates an image of what currently is drawn on the canvas.
     * <p>
     * Throws an {@link ActivitiImageException} when {@link #close()} is already
     * called.
     */
    public InputStream generateImage() {
        if (closed) {
            throw new ActivitiImageException("ProcessDiagramGenerator already closed");
        }

        try {
            ByteArrayOutputStream stream = new ByteArrayOutputStream();
            Writer out;
            out = new OutputStreamWriter(stream, "UTF-8");
            g.stream(out, true);
            return new ByteArrayInputStream(stream.toByteArray());
        } catch (UnsupportedEncodingException | SVGGraphics2DIOException e) {
            throw new ActivitiImageException("Error while generating process image", e);
        }
    }

    /**
     * Closes the canvas which dissallows further drawing and releases graphical
     * resources.
     */
    public void close() {
        g.dispose();
        closed = true;
    }

    public void drawNoneStartEvent(String id, String name, GraphicInfo graphicInfo) {
        drawStartEvent(id, name, graphicInfo, null);
    }

    public void drawTimerStartEvent(String id, String name, GraphicInfo graphicInfo) {
        drawStartEvent(id, name, graphicInfo, TIMER_IMAGE);

View on GitHub (pinned to 56435b1a97)