spring-projects/spring-boot · error · IllegalStateException
Unable to load layers XSD
Error message
Unable to load layers XSD
What it means
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.
Source
Thrown at build-plugin/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/CustomLayersProvider.java:82
private void validate(Document document) {
Schema schema = loadSchema();
try {
Validator validator = schema.newValidator();
validator.validate(new DOMSource(document));
}
catch (SAXException | IOException ex) {
throw new IllegalStateException("Invalid layers.xml configuration", ex);
}
}
private Schema loadSchema() {
try {
SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
return factory.newSchema(getClass().getResource("layers.xsd"));
}
catch (SAXException ex) {
throw new IllegalStateException("Unable to load layers XSD");
}
}
private List<ContentSelector<String>> getApplicationSelectors(Element root) {
return getSelectors(root, "application", (element) -> getSelector(element, ApplicationContentFilter::new));
}
private List<ContentSelector<Library>> getLibrarySelectors(Element root) {
return getSelectors(root, "dependencies", (element) -> getLibrarySelector(element, LibraryContentFilter::new));
}
private List<Layer> getLayers(Element root) {
Element layerOrder = getChildElement(root, "layerOrder");
if (layerOrder == null) {
return Collections.emptyList();
}
return getChildNodeTextContent(layerOrder, "layer").stream().map(Layer::new).toList();
}View on GitHub (pinned to 5b2dbdbb8b)
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.
Example fix
// remove corrupt cached plugin and re-resolve rm -rf ~/.m2/repository/org/springframework/boot/spring-boot-maven-plugin mvn -U package
Defensive patterns
Strategy: validation
Validate before calling
// Verify the plugin jar in the local repo is intact before building
import java.io.File;
import java.util.jar.JarFile;
boolean pluginJarHasXsd(File pluginJar) throws java.io.IOException {
try (JarFile jf = new JarFile(pluginJar)) {
return jf.getEntry("org/springframework/boot/maven/layers.xsd") != null;
}
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Invalid layers.xml configuration
- Failed to load layers configuration with name '%s': '%s' not
- Failed to process custom layers configuration {}
- Multiple '{}' nodes found
- Could not build classpath
AI-assisted analysis of spring-projects/spring-boot@5b2dbdbb8b (2026-08-04).
Data as JSON: /data/errors/a7e6016eef8a98c3.json.
Report an issue: GitHub.