{"id":"a7e6016eef8a98c3","repo":"spring-projects/spring-boot","slug":"unable-to-load-layers-xsd","errorCode":null,"errorMessage":"Unable to load layers XSD","messagePattern":"Unable to load layers XSD","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":82,"sourceCode":"\n\tprivate void validate(Document document) {\n\t\tSchema schema = loadSchema();\n\t\ttry {\n\t\t\tValidator validator = schema.newValidator();\n\t\t\tvalidator.validate(new DOMSource(document));\n\t\t}\n\t\tcatch (SAXException | IOException ex) {\n\t\t\tthrow new IllegalStateException(\"Invalid layers.xml configuration\", ex);\n\t\t}\n\t}\n\n\tprivate Schema loadSchema() {\n\t\ttry {\n\t\t\tSchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);\n\t\t\treturn factory.newSchema(getClass().getResource(\"layers.xsd\"));\n\t\t}\n\t\tcatch (SAXException ex) {\n\t\t\tthrow new IllegalStateException(\"Unable to load layers XSD\");\n\t\t}\n\t}\n\n\tprivate List<ContentSelector<String>> getApplicationSelectors(Element root) {\n\t\treturn getSelectors(root, \"application\", (element) -> getSelector(element, ApplicationContentFilter::new));\n\t}\n\n\tprivate List<ContentSelector<Library>> getLibrarySelectors(Element root) {\n\t\treturn getSelectors(root, \"dependencies\", (element) -> getLibrarySelector(element, LibraryContentFilter::new));\n\t}\n\n\tprivate List<Layer> getLayers(Element root) {\n\t\tElement layerOrder = getChildElement(root, \"layerOrder\");\n\t\tif (layerOrder == null) {\n\t\t\treturn Collections.emptyList();\n\t\t}\n\t\treturn getChildNodeTextContent(layerOrder, \"layer\").stream().map(Layer::new).toList();\n\t}","sourceCodeStart":64,"sourceCodeEnd":100,"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#L64-L100","documentation":"Thrown by CustomLayersProvider.loadSchema as an IllegalStateException when SchemaFactory.newSchema(getClass().getResource(\"layers.xsd\")) throws a SAXException. The XSD is bundled inside the plugin jar itself (org/springframework/boot/maven/layers.xsd), so under normal operation this never fires. It indicates a corrupted plugin installation, a classloading issue, or a build that has shaded/modified the plugin jar so the resource is missing or malformed.","triggerScenarios":"The plugin jar on disk is truncated or corrupted; a custom classloader/shaded jar has stripped or relocated layers.xsd; an OSS Nexus/Artifactory proxy served a partially downloaded plugin jar; running with a forked plugin that resolves a broken plugin dependency.","commonSituations":"A corrupted download of spring-boot-maven-plugin cached in ~/.m2/repository; a corporate mirror with a partially-synced artifact; an unusual shading/relocation of the plugin.","solutions":["Delete the cached spring-boot-maven-plugin jar from ~/.m2/repository/org/springframework/boot/spring-boot-maven-plugin/ and re-resolve.","Force re-download with mvn -U clean package.","Verify the plugin jar integrity: unzip -l ~/.m2/.../spring-boot-maven-plugin-<ver>.jar | grep layers.xsd.","Pin the plugin to a known-good version if a specific version's jar is corrupt."],"exampleFix":"// remove corrupt cached plugin and re-resolve\nrm -rf ~/.m2/repository/org/springframework/boot/spring-boot-maven-plugin\nmvn -U package","handlingStrategy":"validation","validationCode":"// Verify the plugin jar in the local repo is intact before building\nimport java.io.File;\nimport java.util.jar.JarFile;\n\nboolean pluginJarHasXsd(File pluginJar) throws java.io.IOException {\n    try (JarFile jf = new JarFile(pluginJar)) {\n        return jf.getEntry(\"org/springframework/boot/maven/layers.xsd\") != null;\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Delete and re-resolve the plugin if you suspect corruption: rm -rf ~/.m2/repository/org/springframework/boot/spring-boot-maven-plugin && mvn -U.","Use a trusted Maven mirror and checksum verification.","Pin the plugin version to a released, verified version."],"tags":["maven","spring-boot","layers","xsd","plugin-corruption"],"analyzedSha":"5b2dbdbb8be64415eb6552f81ff7c449c8d251e6","analyzedAt":"2026-08-04T18:53:14.967Z","schemaVersion":2}