Page 1 of 1

Null pointer exception while creating package and tparagraph

PostPosted: Sat Oct 15, 2011 1:54 am
by drgiri
I am creating a word docx document using docx4j in eclipse.

If I use,
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
to create the package, and save, the blank file is created and can be opened in word.

But when I try to add the paragraphs using the following code I get "Null Pointer Exception"

objMainPart.addStyledParagraphOfText(String styleId, String text)

If I avoid these convenient methods and use the full code as given in the getting started document the code works.

The actual Error is due to jaxbElement is NULL.

Any information on this ?


Eclipse Ver : Helios
OS : XP
JDK 1.6
docx4j ver 2.7.0

Re: Null pointer exception while creating package and tparag

PostPosted: Wed Oct 19, 2011 12:53 am
by jason
Works for me (albeit tested with 2.7.1 - I've done exactly this for an article to accompany the release announcement).

Where is the NPE coming from? The createPackage method does setJaxbElement

Re: Null pointer exception while creating package and tparag

PostPosted: Fri Nov 11, 2011 2:28 am
by drgiri
Thanks. This works in my machine.