hibernate/hibernate-orm · error · ArchiveException
Unable to access stream from jar file [%s] for entry [%s]
Error message
Unable to access stream from jar file [%s] for entry [%s]
What it means
While visiting entries of a jar during archive scanning, JarFile.getInputStream(zipEntry) throws IOException and Hibernate wraps it as ArchiveException naming the jar file and the zip entry. The original IOException is not chained, so the jar/entry names in the message are the only debugging clues — typically a corrupted, locked, or unreadable jar.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/boot/archive/internal/ExplodedArchiveDescriptor.java:152
try (final JarFile jarFile = new JarFile(rootFile)) {
final Enumeration<? extends ZipEntry> entries = jarFile.entries();
while ( entries.hasMoreElements() ) {
final ZipEntry zipEntry = entries.nextElement();
if ( zipEntry.isDirectory() ) {
continue;
}
final String name = extractName( zipEntry );
if ( !name.endsWith( ".class" ) ) {
continue;
}
final String relativeName = extractRelativeName( zipEntry );
final InputStreamAccess inputStreamAccess;
try {
inputStreamAccess = buildByteBasedInputStreamAccess( name, jarFile.getInputStream( zipEntry ) );
}
catch (IOException e) {
throw new ArchiveException(
String.format(
"Unable to access stream from jar file [%s] for entry [%s]",
jarFile.getName(),
zipEntry.getName()
)
);
}
// todo (jpa4) : for now, pass null
entryConsumer.accept( new ArchiveEntryImpl(
name,
relativeName,
new URL( "jar:" + entryUriBase + "!/" + relativeName ).toURI(),
inputStreamAccess
) );
}
}
catch (IOException e) {View on GitHub (pinned to fad1729dce)
Solutions
- Run jar tf <jar> / unzip -t <jar> on the named jar to verify integrity; replace it if broken.
- Ensure nothing locks or rewrites the jar during Hibernate scanning (stop the server before redeploy, exclude the deploy dir from antivirus).
- Adopt atomic deployments (copy to temp, then rename) so scanners never see partial archives.
Defensive patterns
Strategy: try-catch
Try / catch
Catch org.hibernate.boot.archive.spi.ArchiveException around SessionFactory build. The message names the jar and entry (the IOException is not chained): verify that jar with jar tf/ unzip -t; if a redeploy was in flight, retry once after it completes; if corrupted, replace the jar.
Prevention
- Stop servers or quiesce redeploys before Hibernate scans archives.
- Exclude deploy directories from antivirus real-time scanning on Windows.
- Validate jars in CI so corrupted artifacts never reach deployment.
When it happens
Trigger: Opening an input stream for a .class entry inside the scanned jar fails: broken zip central directory, truncated entry, jar locked by another process (most commonly Windows), or the file disappearing mid-scan.
Common situations: Windows file locks during redeploy; partially copied jars in container images; antivirus interfering with reads; parallel deployment tooling mutating archives during startup.
Related errors
- Unable to extract bytes from InputStream
- Error accessing jar file [<rootFilePath>]
- Unable to determine JAR Url from <url>. Cause: <cause>
- Unable to convert jar File to URL [<jarFileReference>]
- Unable to obtain input stream from [{}]
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/e4efe1c5a12e6165.
Report an issue: GitHub.