{"record":{"id":"5fba00096a6eff8d","repo":"hibernate/hibernate-orm","slug":"file-must-exist-filepath","errorCode":null,"errorMessage":"File must exist : <filePath>","messagePattern":"File must exist : <filePath>","errorType":"exception","errorClass":"HibernateException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/archive/internal/FileInputStreamAccess.java","lineNumber":29,"sourceCode":"import java.io.BufferedInputStream;\nimport java.io.File;\nimport java.io.FileInputStream;\nimport java.io.FileNotFoundException;\nimport java.io.InputStream;\nimport java.io.Serializable;\n\n/// An InputStreamAccess implementation based on a File reference\n///\n/// @author Steve Ebersole\npublic class FileInputStreamAccess implements InputStreamAccess, Serializable {\n\tprivate final String name;\n\tprivate final File file;\n\n\tpublic FileInputStreamAccess(String name, File file) {\n\t\tthis.name = name;\n\t\tthis.file = file;\n\t\tif ( ! file.exists() ) {\n\t\t\tthrow new HibernateException( \"File must exist : \" + file.getAbsolutePath() );\n\t\t}\n\t}\n\n\t@Override\n\tpublic String getStreamName() {\n\t\treturn name;\n\t}\n\n\t@Override\n\tpublic InputStream accessInputStream() {\n\t\ttry {\n\t\t\treturn new BufferedInputStream( new FileInputStream( file ) );\n\t\t}\n\t\tcatch (FileNotFoundException e) {\n\t\t\t// should never ever ever happen, but...\n\t\t\tthrow new ArchiveException(\n\t\t\t\t\t\"File believed to exist based on File.exists threw error when passed to FileInputStream ctor\",\n\t\t\t\t\te","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/archive/internal/FileInputStreamAccess.java#L11-L47","documentation":"Constructor guard in FileInputStreamAccess: it is created around a File handle that the caller claims is readable, but file.exists() is false, so an input stream could never be opened later. It indicates the caller passed a stale or wrong File path (name is kept separately from the actual file).","triggerScenarios":"A jar-file or archive path configured for scanning (persistence.xml <jar-file>, hibernate.archive.scanner input, or programmatic addArchive) points to a file that does not exist.","commonSituations":"Typo in the configured path; build output not yet produced; running in a working directory different from the one the relative path assumes.","solutions":["Check that the configured file path exists and is readable.","Fix typos and verify relative paths resolve from the expected working directory.","Ensure the build produced the jar/classes directory before starting Hibernate."],"exampleFix":"Confirm the file path configured for the archive exists before creating the FileInputStreamAccess. Fix the path in your persistence.xml or configuration, or ensure the file is present at deployment time.","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}