{"record":{"id":"049349932fe6f195","repo":"hibernate/hibernate-orm","slug":"unable-to-locate-schema-s-via-classpath","errorCode":null,"errorMessage":"Unable to locate schema [%s] via classpath","messagePattern":"Unable to locate schema \\[(.+?)\\] via classpath","errorType":"exception","errorClass":"XsdException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/cfgxml/internal/JaxbCfgProcessor.java","lineNumber":157,"sourceCode":"\t}\n\n\tprivate Schema schema;\n\n\tprivate Schema schema() {\n\t\tif ( schema == null ) {\n\t\t\tschema = resolveLocalSchema( \"org/hibernate/hibernate-configuration-4.0.xsd\" );\n\t\t}\n\t\treturn schema;\n\t}\n\n\tprivate Schema resolveLocalSchema(String schemaName) {\n\t\treturn resolveLocalSchema( schemaName, W3C_XML_SCHEMA_NS_URI );\n\t}\n\n\tprivate Schema resolveLocalSchema(String schemaName, String schemaLanguage) {\n\t\tfinal URL url = classLoaderService.locateResource( schemaName );\n\t\tif ( url == null ) {\n\t\t\tthrow new XsdException( \"Unable to locate schema [\" + schemaName + \"] via classpath\", schemaName );\n\t\t}\n\t\ttry {\n\t\t\tfinal var schemaStream = url.openStream();\n\t\t\ttry {\n\t\t\t\treturn SchemaFactory.newInstance( schemaLanguage )\n\t\t\t\t\t\t.newSchema( new StreamSource( url.openStream() ) );\n\t\t\t}\n\t\t\tcatch ( SAXException | IOException e ) {\n\t\t\t\tthrow new XsdException( \"Unable to load schema [\" + schemaName + \"]\", e, schemaName );\n\t\t\t}\n\t\t\tfinally {\n\t\t\t\ttry {\n\t\t\t\t\tschemaStream.close();\n\t\t\t\t}\n\t\t\t\tcatch ( IOException e ) {\n\t\t\t\t\tJAXB_LOGGER.problemClosingSchemaStream( e.toString() );\n\t\t\t\t}\n\t\t\t}","sourceCodeStart":139,"sourceCodeEnd":175,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/cfgxml/internal/JaxbCfgProcessor.java#L139-L175","documentation":"Error \"Unable to locate schema [%s] via classpath\" thrown in hibernate/hibernate-orm.","triggerScenarios":"The XSD schema used to validate the configuration cannot be located or loaded.","commonSituations":"Custom schema resolution failing because the schema resource is missing from the classpath or the schema URL is unreachable.","solutions":["Ensure the schema resource (XSD) is packaged on the classpath at the expected location (org/hibernate/...).","If running with a custom classloader or modular environment, make sure the hibernate-core resources are visible.","Do not strip resource files when shading/minimizing the jar."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}