Bug 61612 - Caught org.apache.poi.openxml4j.exceptions.OpenXML4JRuntimeException: Rule M2.4 exception
Summary: Caught org.apache.poi.openxml4j.exceptions.OpenXML4JRuntimeException: Rule M2...
Status: RESOLVED INVALID
Alias: None
Product: POI
Classification: Unclassified
Component: XWPF (show other bugs)
Version: 3.16-FINAL
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-10-13 09:36 UTC by amseager
Modified: 2017-12-28 14:07 UTC (History)
1 user (show)



Attachments
File which triggered an exception (152 bytes, application/zip)
2017-10-13 09:38 UTC, amseager
Details
Another example, triggered that exception too (3.63 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2017-10-13 09:40 UTC, amseager
Details

Note You need to log in before you can comment on or make changes to this bug.
Description amseager 2017-10-13 09:36:47 UTC
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)
Comment 1 amseager 2017-10-13 09:38:35 UTC
Created attachment 35415 [details]
File which triggered an exception

Couldn't send it directly (Bugzilla rased an error), so I zipped it
Comment 2 amseager 2017-10-13 09:40:24 UTC
Created attachment 35416 [details]
Another example, triggered that exception too
Comment 3 Dominik Stadler 2017-12-28 14:07:37 UTC
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.