Tried to open docx file in that way: File wordFile = new File(wordFilePath); OPCPackage wordPackage = OPCPackage.open(wordFile, PackageAccess.READ_WRITE); XWPFDocument wordDocument = new XWPFDocument(wordPackage); Then I caught this exception: Exception in thread "main" org.apache.poi.openxml4j.exceptions.OpenXML4JRuntimeException: Rule M2.4 exception : this error should NEVER happen! If you can provide the triggering file, then please raise a bug at https://bz.apache.org/bugzilla/enter_bug.cgi?product=POI and attach the file that triggers it, thanks! at org.apache.poi.openxml4j.opc.internal.ContentTypeManager.getContentType(ContentTypeManager.java:340) at org.apache.poi.openxml4j.opc.internal.ContentTypeManager.removeContentType(ContentTypeManager.java:253) at org.apache.poi.openxml4j.opc.OPCPackage.removePart(OPCPackage.java:1020) at org.apache.poi.openxml4j.opc.PackagePart.getOutputStream(PackagePart.java:519) at org.apache.poi.xwpf.usermodel.XWPFDocument.commit(XWPFDocument.java:764) at org.apache.poi.POIXMLDocumentPart.onSave(POIXMLDocumentPart.java:414) at org.apache.poi.POIXMLDocument.write(POIXMLDocument.java:242)
Created attachment 35415 [details] File which triggered an exception Couldn't send it directly (Bugzilla rased an error), so I zipped it
Created attachment 35416 [details] Another example, triggered that exception too
The first zip contains an document with zero bytes length. The second does not reproduce the problem for me with the latest version of POI. Therefore I am closing this as INVALID for now, if this is still a problem for you please re-run the example with the latest version of Apache POI and then reopen and attach both the triggering document and the full self-sufficient code for reproducing the problem here.