https://bz.apache.org/bugzilla/show_bug.cgi?id=59378
Bug ID: 59378
Summary: Docx file corruption on write - The part /_rels/.rels
does not have any content type
Product: POI
Version: 3.15-dev
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P2
Component: XWPF
Assignee: [email protected]
Reporter: [email protected]
Created attachment 33805
--> https://bz.apache.org/bugzilla/attachment.cgi?id=33805&action=edit
File corrupted after a write
Some docx files that are fine to Word become corrupt after being opened and
saved, even without any modifications.
The attached file exhibits this behavior:
- The file can be opened fine with Word
- The file can be opened fine with POI through XWPFDocument
- On save by POI, the file cannot be opened by Word (the error message
indicates that the document is corrupt but can be repaired)
- On reopen by POI through XWPFDocument, an InvalidFormatException is thrown
XWPFDocument doc = new XWPFDocument( [ input file ] );
ByteArrayOutputStream out = new ByteArrayOutputStream();
doc.write(out);
out.close();
XWPFDocument doc2 = new XWPFDocument(new
ByteArrayInputStream(out.toByteArray()));
This code throws the following exception:
org.apache.poi.openxml4j.exceptions.InvalidFormatException: The part
/_rels/.rels does not have any content type ! Rule: Package require content
types when retrieving a part from a package. [M.1.14]
org.apache.poi.POIXMLException:
org.apache.poi.openxml4j.exceptions.InvalidFormatException: The part
/_rels/.rels does not have any content type ! Rule: Package require content
types when retrieving a part from a package. [M.1.14]
at org.apache.poi.util.PackageHelper.open(PackageHelper.java:39)
at
org.apache.poi.xwpf.usermodel.XWPFDocument.<init>(XWPFDocument.java:128)
[...]
Caused by: org.apache.poi.openxml4j.exceptions.InvalidFormatException: The
part /_rels/.rels does not have any content type ! Rule: Package require
content types when retrieving a part from a package. [M.1.14]
at
org.apache.poi.openxml4j.opc.ZipPackage.getPartsImpl(ZipPackage.java:291)
at
org.apache.poi.openxml4j.opc.OPCPackage.getParts(OPCPackage.java:713)
at
org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:296)
at org.apache.poi.util.PackageHelper.open(PackageHelper.java:37)
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]