{"record":{"id":"c8b07a66c8bd6361","repo":"flowable/flowable-engine","slug":"error-while-evaluating-the-following-xpath-express-c8b07a","errorCode":null,"errorMessage":"Error while evaluating the following XPath expression on a BPMN XML document: '%s'.","messagePattern":"Error while evaluating the following XPath expression on a BPMN XML document: '(.+?)'\\.","errorType":"exception","errorClass":"ActivitiException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/bpmn/diagram/ProcessDiagramLayoutFactory.java","lineNumber":346,"sourceCode":"            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)\n                            && !\"lane\".equals(elementLocalName)\n                            && !\"textAnnotation\".equals(elementLocalName)\n                            && !\"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 ActivitiException(\"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\"))\n                && \"5.0\".equals(bpmnModel.getDocumentElement().getAttribute(\"exporterVersion\"));\n    }\n\n}\n","sourceCodeStart":328,"sourceCodeEnd":362,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/bpmn/diagram/ProcessDiagramLayoutFactory.java#L328-L362","documentation":"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.","triggerScenarios":"fixFlowNodePositionsIfModelFromAdonis, when an XPath expression does not compile against the document context or fails during evaluation of the Adonis-style BPMN DI document.","commonSituations":"BPMN DI documents lacking the namespaces/attributes the Adonis-specific XPath expects; documents not actually produced by Adonis import; engine/JDK XPath behavior differences.","solutions":["Verify the BPMN XML actually comes from an Adonis import before this correction path runs","Check the document contains the elements/namespaces the XPath targets","Regenerate the diagram DI section with a standard BPMN tool to bypass the Adonis fix-up"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    layout = factory.getProcessDiagramLayout(bpmnStream, imageStream);\n} catch (org.activiti.engine.ActivitiException e) {\n    if (e.getMessage().startsWith(\"Error while evaluating the following XPath\")) {\n        // document is not Adonis-generated or DI section is malformed; use standard layout\n    }\n}","preventionTips":["Only run Adonis-imported models through this path","Check that DI sections contain the expected elements/namespaces","Prefer standard BPMN DI output from modeling tools"],"tags":["xpath","xml","bpmn","adonis"],"backgroundTag":"xml-parse-failed","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"}