Bug 52449 - NullPointerException in org.apache.poi.xwpf.usermodel.XWPFStyles.commit()
Summary: NullPointerException in org.apache.poi.xwpf.usermodel.XWPFStyles.commit()
Alias: None
Product: POI
Classification: Unclassified
Component: XWPF (show other bugs)
Version: 3.8-dev
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2012-01-11 09:28 UTC by Niels S. Hansen
Modified: 2012-01-11 14:02 UTC (History)
0 users

Example word document (18.41 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2012-01-11 09:28 UTC, Niels S. Hansen

Note You need to log in before you can comment on or make changes to this bug.
Description Niels S. Hansen 2012-01-11 09:28:21 UTC
Created attachment 28137 [details]
Example word document

This has been observed in version 3.8-beta5

NullPointerException when reading and subsequently writing attached document.

	at org.apache.poi.xwpf.usermodel.XWPFStyles.commit(XWPFStyles.java:104)
	at org.apache.poi.POIXMLDocumentPart.onSave(POIXMLDocumentPart.java:313)
	at org.apache.poi.POIXMLDocumentPart.onSave(POIXMLDocumentPart.java:317)
	at org.apache.poi.POIXMLDocumentPart.onSave(POIXMLDocumentPart.java:317)
	at org.apache.poi.POIXMLDocument.write(POIXMLDocument.java:173)

Example program that reproduces the error:
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import java.io.FileInputStream;
import java.io.FileOutputStream;

public class GivesNullPointer {

    public static void main(String[] args) throws Exception {
        XWPFDocument doc = new XWPFDocument(new FileInputStream("Wordmerge.docx"));

        doc.write(new FileOutputStream("out.docx"));
Comment 1 Nick Burch 2012-01-11 14:02:51 UTC
This is caused by the sample document having a glossary, which we don't currently handle. Unfortunately, the glossary has styles and settings, which we do, but we weren't properly reading the glossary styles/settings in. This broke at write time

Should be fixed in r1230045.