Page 1 of 1

NPE from running samples - Header Footer with Image

PostPosted: Fri Sep 10, 2010 8:42 am
by seenaah
Hi all,

I am trying to add images inside header and footer. I just copy and pasted docx4j sample from:

http://dev.plutext.org/trac/docx4j/brow ... ooter.java

After running I am getting this exception:

Code: Select all
log4j:WARN No appenders could be found for logger (org.docx4j.openpackaging.parts.PartName).
log4j:WARN Please initialize the log4j system properly.
JAXB: RI not present.  Trying Java 6 implementation.
JAXB: Using Java 6 implementation.
Exception in thread "main" java.lang.NullPointerException
   at org.docx4j.openpackaging.parts.WordprocessingML.BinaryPartAbstractImage.createImagePart(BinaryPartAbstractImage.java:190)
   at test.HeaderFooter.newImage(HeaderFooter.java:130)
   at test.HeaderFooter.getHdr(HeaderFooter.java:76)
   at test.HeaderFooter.createHeaderPart(HeaderFooter.java:65)
   at test.HeaderFooter.main(HeaderFooter.java:44)


I am using docx4j-2.5.0.jar and windows seven.

By the way, I am able to add header and footers without images without problem. The problem is when I am sending my header part to BinaryPartAbstractImage.createImagePart as it is said in your sample.

Any ideas what am I missing?

Thanks in advance for your time and consideration.

Re: NPE from running samples - Header Footer with Image

PostPosted: Fri Sep 10, 2010 10:40 am
by jason
Please use http://dev.plutext.org/docx4j/docx4j-ni ... 100907.jar instead

v2.5.0 was missing:

Code: Select all
      // Ensure the relationships part exists
      if (sourcePart.getRelationshipsPart()==null)
         RelationshipsPart.createRelationshipsPartForPart(sourcePart);

Re: NPE from running samples - Header Footer with Image

PostPosted: Sat Sep 11, 2010 1:27 am
by seenaah
Thanks a lot for your quick response. :)