{"id":"6f76697bc7866ee5","repo":"spring-projects/spring-boot","slug":"multiple-nodes-found","errorCode":null,"errorMessage":"Multiple '{}' nodes found","messagePattern":"Multiple '(.+?)' nodes found","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"build-plugin/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/CustomLayersProvider.java","lineNumber":167,"sourceCode":"\tprivate List<String> getChildNodeTextContent(Element element, String tagName) {\n\t\tList<String> patterns = new ArrayList<>();\n\t\tNodeList nodes = element.getElementsByTagName(tagName);\n\t\tfor (int i = 0; i < nodes.getLength(); i++) {\n\t\t\tNode node = nodes.item(i);\n\t\t\tif (node instanceof Element) {\n\t\t\t\tpatterns.add(node.getTextContent());\n\t\t\t}\n\t\t}\n\t\treturn patterns;\n\t}\n\n\tprivate @Nullable Element getChildElement(Element element, String tagName) {\n\t\tNodeList nodes = element.getElementsByTagName(tagName);\n\t\tif (nodes.getLength() == 0) {\n\t\t\treturn null;\n\t\t}\n\t\tif (nodes.getLength() > 1) {\n\t\t\tthrow new IllegalStateException(\"Multiple '\" + tagName + \"' nodes found\");\n\t\t}\n\t\treturn (Element) nodes.item(0);\n\t}\n\n}\n","sourceCodeStart":149,"sourceCodeEnd":173,"githubUrl":"https://github.com/spring-projects/spring-boot/blob/5b2dbdbb8be64415eb6552f81ff7c449c8d251e6/build-plugin/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/CustomLayersProvider.java#L149-L173","documentation":"Thrown by CustomLayersProvider.getChildElement as an IllegalStateException when getElementsByTagName(tagName) returns more than one matching child for a node that must be unique. The method is used for top-level singleton elements of layers.xml — application, dependencies, and layerOrder — so the error means the document contains duplicates of one of those. tagName is interpolated into the message so the offending element name is shown.","triggerScenarios":"A layers.xml with two <application> blocks, two <dependencies> blocks, or two <layerOrder> blocks; copy-paste errors where a block was duplicated; merging two layers.xml files without removing duplicates.","commonSituations":"Hand-editing and accidentally duplicating a section; merging contributions from multiple modules into one layers.xml; outdated tutorial content combined with existing config.","solutions":["Open layers.xml and search for the element named in the message — there will be two.","Remove the duplicate so only one <application>, <dependencies>, and <layerOrder> remains.","Validate the file against layers.xsd after editing.","Use a diff against a known-good layers.xml to spot the duplication."],"exampleFix":"// before\n<layers>\n  <application>...</application>\n  <application>...</application>\n  <layerOrder>...</layerOrder>\n</layers>\n// after\n<layers>\n  <application>...</application>\n  <layerOrder>...</layerOrder>\n</layers>","handlingStrategy":"validation","validationCode":"// Ensure singleton elements appear at most once in layers.xml\nimport org.w3c.dom.Document, Element;\nimport javax.xml.parsers.DocumentBuilderFactory;\nimport java.io.File;\n\nvoid assertSingletons(File layersXml, String... names) throws Exception {\n    Document d = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(layersXml);\n    Element root = d.getDocumentElement();\n    for (String n : names) {\n        int c = root.getElementsByTagName(n).getLength();\n        if (c > 1) throw new IllegalStateException(\"Duplicate '\" + n + \"' nodes: \" + c);\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Review diffs of layers.xml carefully — duplication is usually a copy-paste artifact.","Add an integration test that asserts singleton sections appear once.","Validate against layers.xsd, which also constrains cardinality."],"tags":["maven","spring-boot","layers","xml","validation"],"analyzedSha":"5b2dbdbb8be64415eb6552f81ff7c449c8d251e6","analyzedAt":"2026-08-04T18:53:14.967Z","schemaVersion":2}