{"record":{"id":"2373255b9f7259f2","repo":"flowable/flowable-engine","slug":"could-not-generate-di-boundaryevent-boundaryev","errorCode":null,"errorMessage":"Could not generate DI: boundaryEvent '${boundaryEvent.getId()}' has no attachedToRef","messagePattern":"Could not generate DI: boundaryEvent '(.+?)' has no attachedToRef","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"modules/flowable-bpmn-layout/src/main/java/org/flowable/bpmn/BpmnAutoLayout.java","lineNumber":247,"sourceCode":"        generatedVertices.put(flowElement.getId(), subProcessVertex);\n    }\n\n    protected void handleBoundaryEvents() {\n        for (BoundaryEvent boundaryEvent : boundaryEvents) {\n            mxGeometry geometry = new mxGeometry(0.8, 1.0, eventSize, eventSize);\n            geometry.setOffset(new mxPoint(-(eventSize / 2), -(eventSize / 2)));\n            geometry.setRelative(true);\n            mxCell boundaryPort = new mxCell(null, geometry, \"shape=ellipse;perimeter=ellipsePerimeter\");\n            boundaryPort.setId(\"boundary-event-\" + boundaryEvent.getId());\n            boundaryPort.setVertex(true);\n\n            Object portParent = null;\n            if (boundaryEvent.getAttachedToRefId() != null) {\n                portParent = generatedVertices.get(boundaryEvent.getAttachedToRefId());\n            } else if (boundaryEvent.getAttachedToRef() != null) {\n                portParent = generatedVertices.get(boundaryEvent.getAttachedToRef().getId());\n            } else {\n                throw new RuntimeException(\"Could not generate DI: boundaryEvent '\" + boundaryEvent.getId() + \"' has no attachedToRef\");\n            }\n\n            graph.addCell(boundaryPort, portParent);\n            generatedVertices.put(boundaryEvent.getId(), boundaryPort);\n        }\n    }\n\n    protected void handleSequenceFlow() {\n\n        Hashtable<String, Object> edgeStyle = new Hashtable<>();\n        edgeStyle.put(mxConstants.STYLE_ORTHOGONAL, true);\n        edgeStyle.put(mxConstants.STYLE_EDGE, mxEdgeStyle.ElbowConnector);\n        edgeStyle.put(mxConstants.STYLE_ENTRY_X, 0.0);\n        edgeStyle.put(mxConstants.STYLE_ENTRY_Y, 0.5);\n        graph.getStylesheet().putCellStyle(STYLE_SEQUENCEFLOW, edgeStyle);\n\n        Hashtable<String, Object> boundaryEdgeStyle = new Hashtable<>();\n        boundaryEdgeStyle.put(mxConstants.STYLE_EXIT_X, 0.5);","sourceCodeStart":229,"sourceCodeEnd":265,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-bpmn-layout/src/main/java/org/flowable/bpmn/BpmnAutoLayout.java#L229-L265","documentation":"BpmnAutoLayout generates BPMN DI (diagram interchange) coordinates. For a boundary event it must know which activity the event is attached to; if the boundary event has neither attachedToRefId nor attachedToRef, layout cannot place it and throws RuntimeException.","triggerScenarios":"Programmatically building a BpmnModel with a BoundaryEvent and calling BpmnAutoLayout.layout() without setting attachedToRef/attachedToRefId on the boundary event.","commonSituations":"Code-generated models where the attachment link was skipped; models built from incomplete data; boundary events copied without their parent reference.","solutions":["Set boundaryEvent.setAttachedToRefId(\"<activityId>\") before calling layout()","Or set boundaryEvent.setAttachedToRef(activity) with the target BaseElement","Verify the attached-to activity id exists in the model (it must also be laid out)"],"exampleFix":"// before\nBoundaryEvent be = new BoundaryEvent(); be.setId(\"be1\");\nprocess.addFlowElement(be);\n// after\nBoundaryEvent be = new BoundaryEvent(); be.setId(\"be1\");\nbe.setAttachedToRefId(\"task1\");\nprocess.addFlowElement(be);","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { layout.layout(); } catch (RuntimeException e) { if (e.getMessage().contains(\"has no attachedToRef\")) { /* fix model */ } }","preventionTips":["Set attachedToRefId on every BoundaryEvent before layout"],"tags":["bpmn","auto-layout","di-generation"],"backgroundTag":"missing-required-argument","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"}