Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.util.zip.ZipError: invalid CEN header (bad signature)

Tags:

java

zip

nio

I'm using Java 1.7.0_40 on Red Hat Linux and I have the following code:

Path zipfile = Paths.get(filename);
FileSystem fs = FileSystems.newFileSystem(zipfile, FileTest.class.getClassLoader());

The filename variable points to a zip file that is 788MB. The uncompressed size of the zip file is 8.3GB. When I run the code above I get the following exception:

Exception in thread "main" java.util.zip.ZipError: invalid CEN header (bad signature)
        at com.sun.nio.zipfs.ZipFileSystem.zerror(ZipFileSystem.java:1605)
        at com.sun.nio.zipfs.ZipFileSystem.initCEN(ZipFileSystem.java:1058)
        at com.sun.nio.zipfs.ZipFileSystem.<init>(ZipFileSystem.java:130)
        at com.sun.nio.zipfs.ZipFileSystemProvider.newFileSystem(ZipFileSystemProvider.java:139)
        at java.nio.file.FileSystems.newFileSystem(FileSystems.java:386)
        at FileTest.readFromZip(FileTest.java:35)
        at FileTest.main(FileTest.java:25)

I was under the impression that Java 7 was capable of handling large zip files. Can anyone explain why this is happening?

Thanks.

like image 645
Justin Kredible Avatar asked Mar 20 '14 14:03

Justin Kredible


1 Answers

I too faced the issue in Maven based project. The issue occurred because of corrupted jars. Deleted the jars from .m2 folder and built the project again; and it worked like charm.

like image 173
Puneet Pandey Avatar answered Sep 21 '22 22:09

Puneet Pandey