spring-projects/spring-boot · error · IllegalStateException
File '{}' is not readable
Error message
File '{}' is not readable What it means
ZipFileTarArchive.assertArchiveHasEntries opens the source file with Apache Commons Compress ZipFile.builder().setFile(file).get(). Any IOException — file missing, not a zip, truncated/corrupted, encrypted, or unreadable — is wrapped in IllegalStateException('File <file> is not readable'). This runs in the constructor, so failure prevents the ZipFileTarArchive from being created.
Source
Thrown at buildpack/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/io/ZipFileTarArchive.java:83
public void writeTo(OutputStream outputStream) throws IOException {
TarArchiveOutputStream tar = new TarArchiveOutputStream(outputStream);
tar.setLongFileMode(TarArchiveOutputStream.LONGFILE_POSIX);
try (ZipFile zipFile = ZipFile.builder().setFile(this.zip).get()) {
Enumeration<ZipArchiveEntry> entries = zipFile.getEntries();
while (entries.hasMoreElements()) {
ZipArchiveEntry zipEntry = entries.nextElement();
copy(zipEntry, zipFile.getInputStream(zipEntry), tar);
}
}
tar.finish();
}
private void assertArchiveHasEntries(File file) {
try (ZipFile zipFile = ZipFile.builder().setFile(file).get()) {
Assert.state(zipFile.getEntries().hasMoreElements(), () -> "Archive file '" + file + "' is not valid");
}
catch (IOException ex) {
throw new IllegalStateException("File '" + file + "' is not readable", ex);
}
}
private void copy(ZipArchiveEntry zipEntry, InputStream zip, TarArchiveOutputStream tar) throws IOException {
TarArchiveEntry tarEntry = convert(zipEntry);
tar.putArchiveEntry(tarEntry);
if (tarEntry.isFile()) {
StreamUtils.copyRange(zip, tar, 0, tarEntry.getSize());
}
tar.closeArchiveEntry();
}
private TarArchiveEntry convert(ZipArchiveEntry zipEntry) {
byte linkFlag = (zipEntry.isDirectory()) ? TarConstants.LF_DIR : TarConstants.LF_NORMAL;
String entryName = zipEntry.getName();
Path entryPath = Path.of(entryName);
Assert.state(entryPath.toAbsolutePath().equals(entryPath.toAbsolutePath().normalize()),
() -> "Malformed zip entry name '%s'".formatted(entryName));View on GitHub (pinned to 270dfe353f)
Solutions
- Confirm it is a valid zip: `unzip -l <file>` or `jar tf <file>`.
- Re-generate the archive from the source build.
- Fix read permissions: `chmod +r <file>` and check SELinux labels.
Defensive patterns
Strategy: validation
Validate before calling
// Validate the source zip before constructing ZipFileTarArchive
if (!Files.exists(file.toPath()) || !Files.isReadable(file.toPath())) {
throw new IllegalArgumentException("Zip file missing or unreadable: " + file);
}
try (org.apache.commons.compress.archivers.zip.ZipFile zf =
ZipFile.builder().setFile(file).get()) {
if (!zf.getEntries().hasMoreElements()) {
throw new IllegalArgumentException("Zip file has no entries: " + file);
}
} Try / catch
try {
new ZipFileTarArchive(file, owner);
} catch (IllegalStateException ex) {
if (ex.getCause() instanceof IOException
&& ex.getMessage().startsWith("File '") && ex.getMessage().endsWith("is not readable")) {
// hint: validate with `unzip -l <file>` / regenerate the archive
}
throw ex;
} Prevention
- Validate the source archive (`unzip -l`, `jar tf`) before the build.
- Verify checksums on transferred archives to catch truncation.
- Ensure read permissions on the archive file in CI workspaces.
When it happens
Trigger: new ZipFileTarArchive(file, owner) or TarArchive.fromZip(file, owner) is called with a File that ZipFile cannot open: the file does not exist, is not a zip, is a truncated/corrupted zip, is encrypted, or has read permissions denied.
Common situations: Wrong path to the application archive; a jar/zip corrupted in transfer or by a failed build; file permission denied (chmod, SELinux); an AES-encrypted zip; a file that is actually a tar or plain file.
Related errors
- Error reading Docker configuration file '{}'
- Error creating KeyStore: {}
- zstd compression is not supported
- Failed to create {}
- Failed to add {} to {}
AI-assisted analysis of spring-projects/spring-boot@270dfe353f (2026-08-11).
Data as JSON: /api/errors/e6ac76a5655045fe.
Report an issue: GitHub.