Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » iText »

[iText-questions] NullPointerException when adding table to document

KSchaeuble

2006-08-25

Replies:

I'm trying to piece a report together by creating several parts in
different classes. I first ran this code locally and had no prblems
creating the Pdf. When I now integrate it into my web-app and use a real
object I'm getting an exception while generating the document:
I tried to hunt it down but now am rather clueless where else to look. I
already checked that the text I'm getting from the object is ok.

This is the exception I'm getting:
DocumentException:
java.lang.NullPointerException
    at com.lowagie.text.pdf.PdfChunk.<init>(Unknown Source)
    at com.lowagie.text.pdf.ColumnText.addWaitingPhrase(Unknown
Source)
    at com.lowagie.text.pdf.ColumnText.go(Unknown Source)
    at com.lowagie.text.pdf.PdfPRow.calculateHeights(Unknown Source)
    at com.lowagie.text.pdf.PdfPRow.getMaxHeights(Unknown Source)
    at com.lowagie.text.pdf.PdfPTable.calculateHeights(Unknown Source)
    at com.lowagie.text.pdf.PdfPTable.setTotalWidth(Unknown Source)
    at com.lowagie.text.pdf.ColumnText.goComposite(Unknown Source)
    at com.lowagie.text.pdf.ColumnText.go(Unknown Source)
    at com.lowagie.text.pdf.PdfPRow.calculateHeights(Unknown Source)
    at com.lowagie.text.pdf.PdfPRow.getMaxHeights(Unknown Source)
    at com.lowagie.text.pdf.PdfPTable.calculateHeights(Unknown Source)
    at com.lowagie.text.pdf.PdfPTable.setTotalWidth(Unknown Source)
    at com.lowagie.text.pdf.ColumnText.goComposite(Unknown Source)
    at com.lowagie.text.pdf.ColumnText.go(Unknown Source)
    at com.lowagie.text.pdf.ColumnText.go(Unknown Source)
    at com.lowagie.text.pdf.PdfDocument.addPTable(Unknown Source)
    at com.lowagie.text.pdf.PdfDocument.add(Unknown Source)
    at com.lowagie.text.Document.add(Unknown Source)
    at pmt.reporting.basereporting.ReportGenerator.generateReport(
ReportGenerator.java:57)

And this is where I add my table. The render-method returns a PdfPTable as
expected:

List firstElements = builder.getFirstElements();
for (Iterator iter = firstElements.iterator(); iter.hasNext();) {
    ReportSection firstElement = (ReportSection) iter.next();
    PdfPTable table = new
PdfPTable((PdfPTable)firstElement.render(style));
    document.add(table);
}

I know my description is rather misty but maybe you can give me at least
an idea where else to look.

Thanks a lot!
Karola

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
iText-questions mailing list
iText-questions@(protected)
https://lists.sourceforge.net/lists/listinfo/itext-questions
©2008 junlu.com - Jax Systems, LLC, U.S.A.