title: Error reading Excel .XLSX with Apache POI
body: <p>I am using Apache POI 3.8 libraries to read an XLSX file in a web application. The following code works perfectly fine from a Java console app:</p>
  
  <pre><code>InputStream inputFS = new FileInputStream("test.xlsx");
  Workbook workbook = new XSSFWorkbook(inputFS); // below exception is thrown on this line
  Sheet sheet = workbook.getSheetAt(0);
  </code></pre>
  
  <p>but throws a "read error" when used in the web application. A relevant extract of the stack trace is pasted below:</p>
  
  <pre><code>java.io.IOException: Read error
  at java.io.FileInputStream.readBytes(Native Method) ~[na:1.6.0_31]
  at java.io.FileInputStream.read(Unknown Source) ~[na:1.6.0_31]
  at java.io.FilterInputStream.read(Unknown Source) ~[na:1.6.0_31]
  at java.io.PushbackInputStream.read(Unknown Source) ~[na:1.6.0_31]
  at java.util.zip.ZipInputStream.readFully(Unknown Source) ~[na:1.6.0_31]
  at java.util.zip.ZipInputStream.readLOC(Unknown Source) ~[na:1.6.0_31]
  at java.util.zip.ZipInputStream.getNextEntry(Unknown Source) ~[na:1.6.0_31]
  at org.apache.poi.openxml4j.util.ZipInputStreamZipEntrySource.&lt;init&gt;(ZipInputStreamZipEntrySource.java:51) ~[poi-ooxml-3.8-20120326.jar:3.8]
  at org.apache.poi.openxml4j.opc.ZipPackage.&lt;init&gt;(ZipPackage.java:83) ~[poi-ooxml-3.8-20120326.jar:3.8]
  at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:228) ~[poi-ooxml-3.8-20120326.jar:3.8]
  at org.apache.poi.util.PackageHelper.open(PackageHelper.java:39) ~[poi-ooxml-3.8-20120326.jar:3.8]
  at org.apache.poi.xssf.usermodel.XSSFWorkbook.&lt;init&gt;(XSSFWorkbook.java:187) ~[poi-ooxml-3.8-20120326.jar:3.8]
  at com.corp.ReportManager.parseExcelReport(ReportManager.java:575) [ReportManager.class:na]
  </code></pre>
  
  <p>The following JARs are included in the classpath (in the same order):</p>
  
  <pre><code>poi-3.8-20120326.jar
  poi-ooxml-3.8-20120326.jar
  poi-ooxml-schemas-3.8-20120326.jar
  xbean.jar
  dom4j-1.6.1.jar
  </code></pre>
  
  <p>There does not seem to be an memory related issues since I gathered some heap utilization stats just before invoking the above code. The XLSX file is 1.15 MB in size.</p>
  
  <pre><code>##### Heap utilization statistics [MB] #####
  Used Memory:13 MB
  Free Memory:9 MB
  Total Memory:23 MB
  Max Memory:247 MB
  </code></pre>