{"record":{"id":"f1db3d670035dfe1","repo":"MyCATApache/Mycat-Server","slug":"tagname-elements-length-over-one-f1db3d","errorCode":null,"errorMessage":"${tagName} elements length over one!","messagePattern":"(.+?) elements length over one!","errorType":"exception","errorClass":"ConfigException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/mycat/config/util/ConfigUtil.java","lineNumber":175,"sourceCode":"                if (\"property\".equals(name)) {\n                    String key = e.getAttribute(\"name\");\n                    NodeList nl = e.getElementsByTagName(\"bean\");\n                    if (nl.getLength() == 0) {\n                        String value = e.getTextContent();\n                        map.put(key, StringUtil.isEmpty(value) ? null : value.trim());\n                    } else {\n                        map.put(key, loadBean((Element) nl.item(0)));\n                    }\n                }\n            }\n        }\n        return map;\n    }\n\n    public static BeanConfig loadBean(Element parent, String tagName) {\n        NodeList nodeList = parent.getElementsByTagName(tagName);\n        if (nodeList.getLength() > 1) {\n            throw new ConfigException(tagName + \" elements length over one!\");\n        }\n        return loadBean((Element) nodeList.item(0));\n    }\n\n    public static BeanConfig loadBean(Element e) {\n        if (e == null) {\n            return null;\n        }\n        BeanConfig bean = new BeanConfig();\n        bean.setName(e.getAttribute(\"name\"));\n        Element element = loadElement(e, \"className\");\n        if (element != null) {\n            bean.setClassName(element.getTextContent());\n        } else {\n            bean.setClassName(e.getAttribute(\"class\"));\n        }\n        bean.setParams(loadElements(e));\n        return bean;","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/config/util/ConfigUtil.java#L157-L193","documentation":"ConfigUtil.loadBean requires exactly one XML element with the given tag name. When getElementsByTagName finds more than one, it throws ConfigException before delegating to loadBean(Element). Unlike loadElement it does not check for zero matches, so only the 'more than one' case throws here.","triggerScenarios":"Calling loadBean(parent, tagName) where the XML contains 2+ elements with that tag, e.g. two <connection> or two <property>-holder blocks under one parent.","commonSituations":"Duplicated bean definitions in mycat XML config after merges or scripted config generation; repeating a bean stanza intending to override it instead of adding a second one.","solutions":["Remove or consolidate the duplicate '<tagName>' elements in the XML so exactly one remains","Remember bean definitions cannot be repeated to override — edit the single existing bean instead","If multiple beans are needed, use the collection-loading API (loadBeans/map variant) rather than loadBean"],"exampleFix":"<!-- before -->\n<bean name=\"db1\" .../><bean name=\"db1\" .../>\n<!-- after -->\n<bean name=\"db1\" .../>  <!-- single definition -->","handlingStrategy":"validation","validationCode":"NodeList nl = parent.getElementsByTagName(tagName);\nif (nl.getLength() > 1) throw new ConfigException(\"multiple <\" + tagName + \"> beans defined\");","typeGuard":null,"tryCatchPattern":"try { BeanConfig b = ConfigUtil.loadBean(parent, tag); } catch (ConfigException e) { log.error(\"duplicate bean <{}>; edit the single definition\", tag); throw e; }","preventionTips":["Never duplicate bean tags to 'override' — edit the existing one","Validate XML against a schema that enforces maxOccurs=1","Use unique names for repeated bean-like definitions"],"tags":["config","xml","duplicate"],"backgroundTag":"schema-validation-failed","analyzedSha":"65f8d8beb752f935752f2a0eec0ab017facab9ef","analyzedAt":"2026-09-11T00:12:21.696Z","contentChangedAt":"2026-09-11T00:12:21.696Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}