0

I have the following code in the controller in my web app to open an excel template that I use to generate reports from. Locally, the code below works fine to open the file as a BufferedInputStream and load it with data and then send it to the web client. However, when my web app is released as a war file, instead of getting a BufferedInputStream back I am getting a weblogic.utils.zip.SafeZipFileInputStream back and am unable to covert this into an XSSFWorkbook. The excel file is definitely in the war file and I can see that it is returning something to me, it just does not appear to be the excel file I was expecting. The error that I am receiving when I run from the war file is the following: java.util.zip.ZipException: invalid distance too far back

Any thoughts what I am doing wrong here? Thanks in advance.

InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("/com/mycomp/myapp/exceltemplates/MyExcelTemplate.xlsx");
logger.info("XXXXXXXXXXXXXXXXXXXXXXX  InputStream is=" + is);
DaveB
  • 181
  • 3
  • 11
  • Your war file may be corrupted http://stackoverflow.com/questions/21151669/java-util-zip-zipexception-invalid-distance-too-far-back-while-decompressing http://stackoverflow.com/questions/16594307/zipexception-invalid-distance-too-far-back-error-when-running-app – jdiver May 01 '14 at 19:29
  • I can open the xlsx file from within the war without issue. One possible problem though is that the xlsx file is packaged in a jar within the war, it looks like the InputStream I am getting back is the jar, not the xlsx file within the jar. – DaveB May 01 '14 at 19:39

0 Answers0