hibernate/hibernate-orm · error · ArchiveException

File believed to exist based on File.exists threw error when

Error message

File believed to exist based on File.exists threw error when passed to FileInputStream ctor

What it means

Thrown by FileInputStreamAccess when File.exists() returned true but creating a FileInputStream still failed with FileNotFoundException. This indicates a race (file deleted between checks) or a permission/filesystem issue.

Source

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

		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)

Solutions

  1. Ensure no build or cleanup process deletes the archive while Hibernate is starting.
  2. Check file permissions so the JVM user can read the file.
  3. Confirm the path is a regular file, not a directory or dangling symlink.

Example fix

The file passed a File.exists check but failed to open, typically due to permissions or a race where the file was deleted between the check and the open. Check file permissions and avoid concurrent deletion of the archive.

When it happens

Trigger: The archive file existed when checked but opening it failed: the file was deleted concurrently, is a directory, or the process lacks read permission.

Common situations: Concurrent build/clean processes deleting jars while the application starts; read-only or restricted mount points; SELinux or container filesystem restrictions.


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