hibernate/hibernate-orm · error · HibernateException

File must exist

Error message

File must exist : <filePath>

What it means

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).

Solutions

  1. Check that the configured file path exists and is readable.
  2. Fix typos and verify relative paths resolve from the expected working directory.
  3. Ensure the build produced the jar/classes directory before starting Hibernate.

Example fix

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.
Defensive patterns

Strategy: validation

When it happens

Trigger: 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.

Common situations: Typo in the configured path; build output not yet produced; running in a working directory different from the one the relative path assumes.


AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22). Data as JSON: /api/errors/5fba00096a6eff8d. Report an issue: GitHub.

Appendix: source

Thrown at hibernate-core/src/main/java/org/hibernate/boot/archive/internal/FileInputStreamAccess.java:29

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.Serializable;

/// An InputStreamAccess implementation based on a File reference
///
/// @author Steve Ebersole
public class FileInputStreamAccess implements InputStreamAccess, Serializable {
	private final String name;
	private final File file;

	public FileInputStreamAccess(String name, File file) {
		this.name = name;
		this.file = file;
		if ( ! file.exists() ) {
			throw new HibernateException( "File must exist : " + file.getAbsolutePath() );
		}
	}

	@Override
	public String getStreamName() {
		return name;
	}

	@Override
	public InputStream accessInputStream() {
		try {
			return new BufferedInputStream( new FileInputStream( file ) );
		}
		catch (FileNotFoundException e) {
			// should never ever ever happen, but...
			throw new ArchiveException(
					"File believed to exist based on File.exists threw error when passed to FileInputStream ctor",
					e

View on GitHub (pinned to fad1729dce)