{"record":{"id":"f9d7a590bc4030fb","repo":"flowable/flowable-engine","slug":"error-while-evaluating-the-following-xpath-express","errorCode":null,"errorMessage":"Error while evaluating the following XPath expression on a BPMN XML document: '<expression>'.","messagePattern":"Error while evaluating the following XPath expression on a BPMN XML document: '<expression>'\\.","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/diagram/ProcessDiagramLayoutFactory.java","lineNumber":346,"sourceCode":"    protected Map<String, DiagramNode> fixFlowNodePositionsIfModelFromAdonis(Document bpmnModel, Map<String, DiagramNode> elementBoundsFromBpmnDi) {\n        if (isExportedFromAdonis50(bpmnModel)) {\n            Map<String, DiagramNode> mapOfFixedBounds = new HashMap<>();\n            XPathFactory xPathFactory = XPathFactory.newInstance();\n            XPath xPath = xPathFactory.newXPath();\n            xPath.setNamespaceContext(new Bpmn20NamespaceContext());\n            for (Entry<String, DiagramNode> entry : elementBoundsFromBpmnDi.entrySet()) {\n                String elementId = entry.getKey();\n                DiagramNode elementBounds = entry.getValue();\n                String expression = \"local-name(//bpmn:*[@id = '\" + elementId + \"'])\";\n                try {\n                    XPathExpression xPathExpression = xPath.compile(expression);\n                    String elementLocalName = xPathExpression.evaluate(bpmnModel);\n                    if (!\"participant\".equals(elementLocalName) && !\"lane\".equals(elementLocalName) && !\"textAnnotation\".equals(elementLocalName) && !\"group\".equals(elementLocalName)) {\n                        elementBounds.setX(elementBounds.getX() - elementBounds.getWidth() / 2);\n                        elementBounds.setY(elementBounds.getY() - elementBounds.getHeight() / 2);\n                    }\n                } catch (XPathExpressionException e) {\n                    throw new FlowableException(\"Error while evaluating the following XPath expression on a BPMN XML document: '\" + expression + \"'.\", e);\n                }\n                mapOfFixedBounds.put(elementId, elementBounds);\n            }\n            return mapOfFixedBounds;\n        } else {\n            return elementBoundsFromBpmnDi;\n        }\n    }\n\n    protected boolean isExportedFromAdonis50(Document bpmnModel) {\n        return \"ADONIS\".equals(bpmnModel.getDocumentElement().getAttribute(\"exporter\")) && \"5.0\".equals(bpmnModel.getDocumentElement().getAttribute(\"exporterVersion\"));\n    }\n\n}\n","sourceCodeStart":328,"sourceCodeEnd":361,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/diagram/ProcessDiagramLayoutFactory.java#L328-L361","documentation":"fixFlowNodePositionsIfModelFromAdonis adjusts element coordinates for diagrams exported from the Adonis tool by evaluating XPath expressions against the parsed BPMN DOM. If an XPath expression fails to evaluate (XPathExpressionException), Flowable wraps it in this FlowableException including the failing expression.","triggerScenarios":"getBpmnProcessDiagramLayout processes an Adonis-exported BPMN diagram whose element references or namespaces make one of the hardcoded XPath expressions fail during evaluation.","commonSituations":"BPMN diagrams exported from Adonis with non-standard namespace prefixes; elements missing expected id attributes; Adonis version differences changing the XML structure the XPath expects.","solutions":["Inspect the failing expression in the message and compare against the actual XML structure/namespace prefixes of your Adonis export","Re-export the diagram from Adonis in standard BPMN 2.0 DI format so the Adonis-specific fix-up path is not needed","Normalize namespace prefixes in the XML before layout processing","Open the diagram in a BPMN editor (e.g. Flowable Modeler) and re-save to produce canonical XML"],"exampleFix":"// before: feeding Adonis export directly\nfactory.getBpmnProcessDiagramLayout(adonisXmlStream, imageStream);\n\n// after: use standard BPMN 2.0 DI export\nfactory.getBpmnProcessDiagramLayout(standardBpmnXmlStream, imageStream);","handlingStrategy":"validation","validationCode":"// Prefer standard BPMN 2.0 DI exports; detect Adonis output and re-export first\nif (xml.contains(\"adonis\") || usesAdonisLayout(xml)) {\n    throw new IllegalArgumentException(\"Re-export diagram in standard BPMN 2.0 DI before layout processing\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    layout = factory.getProcessDiagramLayout(xmlStream, imageStream);\n} catch (FlowableException e) {\n    if (e.getMessage().contains(\"XPath expression\")) {\n        // fall back to default layout or re-export the diagram\n    }\n}","preventionTips":["Use standard BPMN 2.0 DI exports rather than Adonis-specific output","Re-save Adonis diagrams in a standard BPMN editor before deployment","Keep namespace prefixes consistent when generating BPMN XML"],"tags":["xpath","xml","bpmn","diagram-layout","adonis"],"backgroundTag":"invalid-regex-pattern","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}