{"record":{"id":"05ffd39e6614f150","repo":"hibernate/hibernate-orm","slug":"unable-to-deserialize-from-cached-file-s","errorCode":null,"errorMessage":"Unable to deserialize from cached file [%s]","messagePattern":"Unable to deserialize from cached file \\[(.+?)\\]","errorType":"exception","errorClass":"MappingException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/jaxb/internal/CacheableFileXmlSource.java","lineNumber":57,"sourceCode":"\t\t\tMappingBinder binder) {\n\t\tfinal var origin = new Origin( SourceType.FILE, xmlFile.getAbsolutePath() );\n\t\treturn fromCacheableFile( xmlFile, serLocation, origin, strict, binder );\n\t}\n\n\tpublic static Binding<? extends JaxbBindableMappingDescriptor> fromCacheableFile(\n\t\t\tFile xmlFile,\n\t\t\tFile serLocation,\n\t\t\tOrigin origin,\n\t\t\tboolean strict,\n\t\t\tMappingBinder binder) {\n\t\tfinal var serFile = resolveSerFile( xmlFile, serLocation );\n\n\t\tif ( strict ) {\n\t\t\ttry {\n\t\t\t\treturn new Binding<>( readSerFile( serFile ), origin );\n\t\t\t}\n\t\t\tcatch ( SerializationException e ) {\n\t\t\t\tthrow new MappingException(\n\t\t\t\t\t\tString.format( \"Unable to deserialize from cached file [%s]\", origin.getName() ) ,\n\t\t\t\t\t\te,\n\t\t\t\t\t\torigin\n\t\t\t\t);\n\t\t\t}\n\t\t\tcatch ( FileNotFoundException e ) {\n\t\t\t\tthrow new MappingException(\n\t\t\t\t\t\tString.format( \"Unable to locate cached file [%s]\", origin.getName() ) ,\n\t\t\t\t\t\te,\n\t\t\t\t\t\torigin\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tif ( !isSerfileObsolete( xmlFile, serFile ) ) {\n\t\t\t\ttry {\n\t\t\t\t\treturn new Binding<>( readSerFile( serFile ), origin );\n\t\t\t\t}","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/jaxb/internal/CacheableFileXmlSource.java#L39-L75","documentation":"In strict mode, CacheableFileXmlSource failed to Java-deserialize the cached binding (.bin) for a mapping file: readSerFile threw SerializationException. The .bin exists but cannot be read back - typically written by a different Hibernate/JDK version or corrupted on disk. Wrapped in a MappingException naming the cached file's Origin.","triggerScenarios":"Bootstrapping with cached-file binding (addCacheableFile-style APIs) in strict mode, where the .bin next to the .hbm.xml was produced by an older hibernate-core, a different JDK, or was truncated/corrupted.","commonSituations":"Upgrading Hibernate without cleaning generated .bin caches; switching JDK major versions; CI artifacts carrying stale .bin files; interrupted builds leaving half-written .bin files.","solutions":["Delete the stale .bin file(s) next to the mapping (find . -name '*.bin' -delete) so the binder regenerates from the XML","Keep hibernate-core version consistent between cache generation and cache reads (same app, no mixed jars)","Regenerate caches after JDK or Hibernate upgrades rather than reusing committed/build .bin files","If using strict reads intentionally, pair them with a build step that refreshes the .bin files"],"exampleFix":"# before: strict read of stale cache\n# -> Unable to deserialize from cached file [...]\n\n# after: drop caches and rebuild\nfind . -name '*.hbm.xml.bin' -delete\nmvn clean package   # or your build; caches are regenerated","handlingStrategy":"fallback","validationCode":"// check cache freshness/consistency before strict use\nFile bin = serializedFileFor(xmlFile);\nif (!bin.exists() || hibernateVersionOf(bin).equals(expectedVersion)) { /* regenerate */ }\nelse if (bin.length() == 0) { bin.delete(); }","typeGuard":null,"tryCatchPattern":"try {\n    return strictCachedBind(xmlFile);\n} catch (MappingException e) {\n    if (e.getCause() instanceof SerializationException) {\n        binFile.delete();          // drop the stale cache\n        return bindFromXml(xmlFile); // regenerate from the source XML\n    }\n    throw e;\n}","preventionTips":["Delete *.bin caches as part of every Hibernate or JDK upgrade","Never commit or ship .bin files between versions","Clean caches in CI builds instead of caching them across dependency changes"],"tags":["hibernate","mapping-cache","serialization","bootstrap","stale-cache"],"backgroundTag":"stale-metadata-cache","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}