1

I have an issue when uncompressing a zip file in my java application. It is a web service packaged as a war file and running under jetty 9.4. This is my (shortened) stack trace

2018-05-10 20:13:48,180 ERROR [ProductPublisherHelper:63] net.lingala.zip4j.exception.ZipException: net.lingala.zip4j.exception.ZipException: compression type not supported
net.lingala.zip4j.exception.ZipException: net.lingala.zip4j.exception.ZipException: net.lingala.zip4j.exception.ZipException: compression type not supported
        at net.lingala.zip4j.unzip.Unzip.initExtractFile(Unzip.java:163)
        at net.lingala.zip4j.unzip.Unzip.initExtractAll(Unzip.java:83)

My server is running under Ubuntu 16.04. This code has worked fine until now. It's just this one file which fails to decompress. At the same time, the same code works perfectly fine under the same conditions (jetty, war, same file to decompress) on Windows...

The file is a large > 1GB compressed TIF file, apart from that I don't think it is anything special. Is there anything in my set up I should check which could explain why it fails under Linux but works under Windows? JDK is 1.8.0_101 in Windows and 1.8.0_171 under Linux.

Thomas
  • 1,967
  • 2
  • 15
  • 22
  • A war could use the java specific compression for .class files. So skip those. – Joop Eggen May 14 '18 at 07:45
  • What do you mean by "skip those"? – Thomas May 16 '18 at 04:46
  • Not unpacking .class zip entries. (That could be not feasible, when the unpacking is done by a third party library.) Those zip entries one could extract using the Java SE zip functionality. – Joop Eggen May 16 '18 at 08:18
  • Sorry, I just realised my test with Windows wasn't actually working. The zip file uses a compression method not supported by Java. I checked and it says method 9. As far as I understand Java only supports a limited number of these and 9 is not included indeed. It also seems that there is no maintianed Java libray for this, so I might need to call a script command line in the background instead... – Thomas May 21 '18 at 11:51
  • Aha, method 9, proprietary DEFLATE64. https://github.com/thejoshwolfe/yauzl/issues/58 – Joop Eggen May 21 '18 at 17:55

1 Answers1

-1

Perhaps there is a problem with the external library you are using. For my projects I use the built-in ZipInputStream.

Create the InputStream: ZipInputStream zis = new ZipInputStream(Files.newInputStream(inputPath))

Browse files in .zip : ZipEntry ze = zis.getNextEntry();

Copy the input from zip to a new file:

try (OutputStream output = Files.newOutputStream(newFile)) { IOUtils.copy(zis, output); }

IOUtils from org.apache.commons.io

R. Daumann
  • 86
  • 1
  • 6