{"record":{"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":"critical","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/270dfe353fb830fd69b823a8a859287ff103854b/build-plugin/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/CustomLayersProvider.java#L64-L100","documentation":"IllegalStateException thrown by CustomLayersProvider.loadSchema when SchemaFactory cannot load the bundled layers.xsd resource as a W3C Schema. The XSD ships inside the plugin's own JAR; failure to construct a Schema from it indicates a classpath/JAR integrity problem rather than a user configuration problem.","triggerScenarios":"getClass().getResource(\"layers.xsd\") returns a URL the SchemaFactory cannot parse (SAXException during newSchema). This is essentially never a user-input issue — the resource itself is missing, corrupted, or shadowed by an incompatible copy.","commonSituations":"Plugin JAR corrupted in local .m2 cache; an old/incompatible spring-boot-maven-plugin version on the classpath shadowing the resolved one; partial download of the plugin artifact; custom classloader tricks stripping resources.","solutions":["Force re-download: `mvn dependency:purge-local-repository -DreResolve=true` or delete ~/.m2/repository/org/springframework/boot/spring-boot-maven-plugin and re-resolve.","Pin a single, known-good spring-boot-maven-plugin version in <pluginManagement> to avoid shadowing.","Verify the plugin JAR integrity (`jar tf` should list org/springframework/boot/maven/layers.xsd).","If the error persists, file a Spring Boot issue — the bundled XSD should always load."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// CI pre-flight: assert the plugin JAR carries the bundled XSD:\n//   jar tf ~/.m2/repository/org/springframework/boot/spring-boot-maven-plugin/<ver>/spring-boot-maven-plugin-<ver>.jar \\\n//     | grep -q org/springframework/boot/maven/layers.xsd\n// If absent, purge and re-resolve.","typeGuard":null,"tryCatchPattern":"try {\n    // invoke goal that loads layers XSD\n} catch (IllegalStateException ex) {\n    if (\"Unable to load layers XSD\".equals(ex.getMessage())) {\n        // purge ~/.m2/.../spring-boot-maven-plugin and re-resolve, then retry\n    }\n    throw ex;\n}","preventionTips":["Pin one spring-boot-maven-plugin version in <pluginManagement> to avoid shadowing.","In CI, start from a clean local repo or use dependency:purge-local-repository periodically.","Verify JAR integrity after download (checksums)."],"tags":["spring-boot","maven-plugin","layers","xsd","classpath"],"backgroundTag":null,"analyzedSha":"270dfe353fb830fd69b823a8a859287ff103854b","analyzedAt":"2026-08-11T19:42:06.541Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}