-1

I am new to Apache POI. I am trying to reading xlsx file using xssf workbook. Its not reading some files and not throwing exception, its directly going to finally block. How to find out the exact root cause. Here's the line am using. Thanks in advance.

FileInputStream inputStream = new FileInputStream(file);

    try {
                Iterator<org.apache.poi.ss.usermodel.Row> rowIterator = null;


                    org.apache.poi.xssf.usermodel.XSSFWorkbook xlsxbook = new org.apache.poi.xssf.usermodel.XSSFWorkbook(inputStream);
                    sheet = xlsxbook.getSheetAt(0);
    }
    catch (Exception e) {
                logger.log(Level.WARNING, "", e);
            } finally {
                try {
                    if (inputStream != null) {
                        inputStream.close();
                    }
                } catch (Exception ioe) {
                    System.out.println(ioe);
                }
            }
user2625094
  • 606
  • 6
  • 12

1 Answers1

1

Its hard to be certain from so little code, but "directly going to finally block" sounds a lot like throwing an exception. If you add the below code before the finally block, does anything get printed?

catch (Throwable t){
   t.printStackTrace();
}
John Angland
  • 446
  • 3
  • 12
  • its throwing java.lang.IllegalAccessError: tried to access method org.apache.poi.util.POILogger.log(ILjava/lang/Object;)V from class org.apache.poi.openxml4j.opc.PackageRelationshipCollection. – user2625094 May 02 '17 at 12:17
  • 1
    You are probably using a bad combination of POI versions. http://stackoverflow.com/questions/33415904/apache-poi-parsing-error – John Angland May 02 '17 at 12:22
  • Ya think so. comparing all the JARS. – user2625094 May 02 '17 at 12:32