When OOXML file is invalid, org.apache.poi.ooxml.extractor.ExtractorFactory#createExtractor throws IllegalArgumentException: public static POITextExtractor createExtractor(OPCPackage pkg) throws IOException, OpenXML4JException, XmlException { ... if (core.size() != 1) { throw new IllegalArgumentException("Invalid OOXML Package received - expected 1 core document, found " + core.size()); } } POI already implements POIXMLException for this type of problem. Other methods all throw this exception: org.apache.poi.ooxml.POIXMLDocumentPart.RelationPart#getPartFromOPCPackage org.apache.poi.ooxml.POIXMLDocumentPart.RelationPart#getPartFromOPCPackage org.apache.poi.xssf.eventusermodel.XSSFReader#XSSFReader Please update the exception of createExtractor, so it is easier to catch this type of problems.
I've reworked the Extractor API for POI 5.0 and the main entry point is now in the main package (org.apache.poi.extractor.ExtractorFactory), which doesn't know about POIXMLException. It only declares a IOException and - if I don't missed something - this wraps all un-/checked exceptions. So if the source exception is important to you, please inspect the exception cause. POIXMLException is anyway a runtime exception - probably because of laziness - and we usually don't declare those.