title: Apache POI Workbook throws java.lang.reflect.InvocationTargetException
body: <p>I am trying to instantiate a <code>Workbook</code> with this code:</p>
  
  <pre><code>Workbook workbook = WorkbookFactory.create(new File(excelWorkbookFilePath));
  </code></pre>
  
  <p>I do it this way because the workbook can either be <code>.xlsx</code> or <code>.xls</code>. However, it ends up throwing this error:</p>
  
  <pre><code>Exception in thread "main" org.apache.poi.POIXMLException: java.lang.reflect.InvocationTargetException
      at org.apache.poi.POIXMLFactory.createDocumentPart(POIXMLFactory.java:65)
      at org.apache.poi.POIXMLDocumentPart.read(POIXMLDocumentPart.java:601)
      at org.apache.poi.POIXMLDocument.load(POIXMLDocument.java:174)
      at org.apache.poi.xssf.usermodel.XSSFWorkbook.&lt;init&gt;(XSSFWorkbook.java:249)
      at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:293)
      at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:252)
      at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:231)
      at com.iconectiv.handle.ExcelHandle.&lt;init&gt;(ExcelHandle.java:43)
  Caused by: java.lang.reflect.InvocationTargetException
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
      at org.apache.poi.xssf.usermodel.XSSFFactory.createDocumentPart(XSSFFactory.java:56)
      at org.apache.poi.POIXMLFactory.createDocumentPart(POIXMLFactory.java:62)
      ... 9 more
  Caused by: java.lang.NoSuchMethodError: org.apache.xmlbeans.XmlOptions.setLoadEntityBytesLimit(I)Lorg/apache/xmlbeans/XmlOptions;
      at org.apache.poi.POIXMLTypeLoader.&lt;clinit&gt;(POIXMLTypeLoader.java:50)
      at org.apache.poi.xssf.model.ThemesTable.&lt;init&gt;(ThemesTable.java:85)
      ... 15 more
  </code></pre>
  
  <p>I did some research and found out that <code>InvocationTargetException</code> is not the real exception, so I tried to catch it with this <code>catch</code> statement:</p>
  
  <pre><code>} catch (InvocationTargetException e) {
      e.getCause().printStackTrace();
  }
  </code></pre>
  
  <p>However, I get an error in Eclipse saying that I can't catch that as it is never thrown from anything. Why am I getting this error? Any help would be appreciated, thanks in advance!</p>
  
  <p>Note: I am using Apache POI 3.14.</p>