flowable/flowable-engine · error · ActivitiException

Error while evaluating the following XPath expression on a…

Error message

Error while evaluating the following XPath expression on a BPMN XML document: '%s'.

What it means

fixFlowNodePositionsIfModelFromAdonis applies Adonis-import corrections by evaluating XPath expressions against the BPMN DOM. Any XPathExpressionException during evaluation is wrapped in an ActivitiException naming the failing expression.

Solutions

  1. Verify the BPMN XML actually comes from an Adonis import before this correction path runs
  2. Check the document contains the elements/namespaces the XPath targets
  3. Regenerate the diagram DI section with a standard BPMN tool to bypass the Adonis fix-up
Defensive patterns

Strategy: try-catch

Try / catch

try {
    layout = factory.getProcessDiagramLayout(bpmnStream, imageStream);
} catch (org.activiti.engine.ActivitiException e) {
    if (e.getMessage().startsWith("Error while evaluating the following XPath")) {
        // document is not Adonis-generated or DI section is malformed; use standard layout
    }
}

Prevention

When it happens

Trigger: fixFlowNodePositionsIfModelFromAdonis, when an XPath expression does not compile against the document context or fails during evaluation of the Adonis-style BPMN DI document.

Common situations: BPMN DI documents lacking the namespaces/attributes the Adonis-specific XPath expects; documents not actually produced by Adonis import; engine/JDK XPath behavior differences.

Related errors


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

Appendix: source

Thrown at modules/flowable5-engine/src/main/java/org/activiti/engine/impl/bpmn/diagram/ProcessDiagramLayoutFactory.java:346

            XPathFactory xPathFactory = XPathFactory.newInstance();
            XPath xPath = xPathFactory.newXPath();
            xPath.setNamespaceContext(new Bpmn20NamespaceContext());
            for (Entry<String, DiagramNode> entry : elementBoundsFromBpmnDi.entrySet()) {
                String elementId = entry.getKey();
                DiagramNode elementBounds = entry.getValue();
                String expression = "local-name(//bpmn:*[@id = '" + elementId + "'])";
                try {
                    XPathExpression xPathExpression = xPath.compile(expression);
                    String elementLocalName = xPathExpression.evaluate(bpmnModel);
                    if (!"participant".equals(elementLocalName)
                            && !"lane".equals(elementLocalName)
                            && !"textAnnotation".equals(elementLocalName)
                            && !"group".equals(elementLocalName)) {
                        elementBounds.setX(elementBounds.getX() - elementBounds.getWidth() / 2);
                        elementBounds.setY(elementBounds.getY() - elementBounds.getHeight() / 2);
                    }
                } catch (XPathExpressionException e) {
                    throw new ActivitiException("Error while evaluating the following XPath expression on a BPMN XML document: '" + expression + "'.", e);
                }
                mapOfFixedBounds.put(elementId, elementBounds);
            }
            return mapOfFixedBounds;
        } else {
            return elementBoundsFromBpmnDi;
        }
    }

    protected boolean isExportedFromAdonis50(Document bpmnModel) {
        return "ADONIS".equals(bpmnModel.getDocumentElement().getAttribute("exporter"))
                && "5.0".equals(bpmnModel.getDocumentElement().getAttribute("exporterVersion"));
    }

}

View on GitHub (pinned to d6d39ce1c6)