Java Mailing List Archive

http://www.junlu.com/

Google
Google
Mailing List
Home
Forum Home
JBoss - Java Application Server
Tomcat - JSP/Servlet container
Struts - A MVC web framework
iText - An open source PDF Java Library
JDOM - JDOM XML Parser
J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition
J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog
JSP - A mailing list about Java Server Pages specification and reference
Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology
Struts & Hibernate
Subjects
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Oracle Connection Pooling in 3 2 2
Servlet : Session invalidate
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Tomcat and webapplication specific java library path
Running a Simple JMS Example
Mapping in workers2 properties
org apache jasper JasperException
Cannot find message resources under key org apache struts action
   MESSAGE
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
url string for connecting jboss to oracle
Value attribute of <html:checkbox
javax servlet ServletException: BeanUtils populate
HTTP Status 404 The requested resource is not available
5 0 18: Windows XP Pro vs Windows 2000
 
Stack overflow error using iText

Stack overflow error using iText

2006-08-01       - By Webber, David (NIH/OD) [C]

 Back
Reply:     1     2     3  

Folks - finally been able to isolate this issue with two samples:

http://www.drrw.net/temp/iText/stackoverflow-sample1.pdf

http://www.drrw.net/temp/iText/stackoverflow-sample2.pdf

When we attempt to run them through iText we get the "stack overflow"
error occurring.

Here's the code fragment of how we are using iText, and here's also the
java log details of the loop that leads to the stack overflow crash.

Thanks, DW

========================================================================
===

private void addReaderData(com.lowagie.text.Document Source code of com.lowagie.text.Document pdfDocument,

                                   PdfReader reader, PdfWriter writer,
String bookmarkText, String attachmentName) throws Throwable {

                       int i = 0;

                       PDFGenerationThrowable pth=null;

                       MessageCollection messages = new
MessageCollection();

                       try {

                                   int n = reader.getNumberOfPages();


                                   PdfContentByte cb =
writer.getDirectContent();

                                   

                                   while (i < n) {

                                               i++;

                                               cat.debug("Add Reader
Data Page # "+i+ attachmentName);


pdfDocument.setPageSize(reader.getPageSizeWithRotation(i));

                                               pdfDocument.newPage();

                                               // pdfDocument.add(new
Paragraph("This is a test"));

                                               PdfImportedPage page =
writer.getImportedPage(reader, i);

                                               int rotation =
reader.getPageRotation(i);



                                               cat.debug("HEIGHT = "


+ reader.getPageSizeWithRotation(i).height());



                                               if (rotation == 90 ||
rotation == 270) {


cb.addTemplate(page, 0, -1f, 1f, 0, 0, reader


.getPageSizeWithRotation(i).height());

                                               } else {


cb.addTemplate(page, 1f, 0, 0, 1f, 0, 0);

                                               }

                                               //
pdfDocument.setFooter(pageFooter);

                                   } // end while

                       }catch(Exception e)

                       {

                                   cat.debug("Exception in
addReaderData method while PDF Rotation", e);

                                   throw e;

                       }

                       catch(StackOverflowError sth)

                       {

                                   cat.debug("Stack over Flow error in
addReaderData method while PDF Rotation", sth);

                                   ArrayList tokens = new ArrayList();

                                   tokens.add(new Integer(i));


tokens.add(bookmarkText+"{"+attachmentName+"}");

                                   pdfErrors.add(new
Message(MessageKeys.EGRANTS_INVALID_PDF_STACK_OVER_FLOW_ERROR, tokens));


                       } catch (Throwable th) {

                                    cat.debug("Exception in
addReaderData method while PDF Rotation",th);

                                   //throw new
StackOverFlowException(i,bookmarkText,new Exception());

                                    throw th;

                       }                      

           } // addReaderData()

==============================================
Log details:

2006-08-01 11:36:57,107 DEBUG Task-0 (See http://ask-0.ora-code.com)
gov.nih.egrants.beantier.processor.EgrantsFE - [GRANT00072741] - Stack
over Flow error in addReaderData method while PDF Rotation

java.lang.StackOverflowError Source code of java.lang.StackOverflowError

           at
com.lowagie.text.pdf.BaseFont Source code of com.lowagie.text.pdf.BaseFont(BaseFont.java:421)

           at
com.lowagie.text.pdf.BaseFont Source code of com.lowagie.text.pdf.BaseFont(BaseFont.java:360)

           at
com.lowagie.text.pdf.BaseFont Source code of com.lowagie.text.pdf.BaseFont(BaseFont.java:332)

           at
com.lowagie.text.Font Source code of com.lowagie.text.Font(Font.java:718)

           at com.lowagie.text.pdf.PdfChunk Source code of com.lowagie.text.pdf.PdfChunk<init>(PdfChunk.java:203)

           at
com.lowagie.text.pdf.PdfDocument Source code of com.lowagie.text.pdf.PdfDocument(PdfDocument.java:1328)

           at com.lowagie.text.Phrase Source code of com.lowagie.text.Phrase(Phrase.java:299)

           at
com.lowagie.text.pdf.PdfDocument Source code of com.lowagie.text.pdf.PdfDocument(PdfDocument.java:1478)

           at
com.lowagie.text.pdf.PdfDocument Source code of com.lowagie.text.pdf.PdfDocument(PdfDocument.java:1935)

           at
com.lowagie.text.pdf.PdfDocument Source code of com.lowagie.text.pdf.PdfDocument(PdfDocument.java:812)

           at
com.lowagie.text.pdf.PdfDocument Source code of com.lowagie.text.pdf.PdfDocument(PdfDocument.java:2071)

           at
com.lowagie.text.pdf.PdfDocument Source code of com.lowagie.text.pdf.PdfDocument(PdfDocument.java:1333)

           at com.lowagie.text.Phrase Source code of com.lowagie.text.Phrase(Phrase.java:299)

           at
com.lowagie.text.pdf.PdfDocument Source code of com.lowagie.text.pdf.PdfDocument(PdfDocument.java:1478)

           at
com.lowagie.text.pdf.PdfDocument Source code of com.lowagie.text.pdf.PdfDocument(PdfDocument.java:1935)

           at
com.lowagie.text.pdf.PdfDocument Source code of com.lowagie.text.pdf.PdfDocument(PdfDocument.java:812)

           at
com.lowagie.text.pdf.PdfDocument Source code of com.lowagie.text.pdf.PdfDocument(PdfDocument.java:2071)

           at
com.lowagie.text.pdf.PdfDocument Source code of com.lowagie.text.pdf.PdfDocument(PdfDocument.java:1333)

           at com.lowagie.text.Phrase Source code of com.lowagie.text.Phrase(Phrase.java:299)


and sequence loops until stack overflows...

-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -----
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
__ ____ ____ ____ ____ ____ ____ ____ ____ ____
iText-questions mailing list
iText-questions@(protected)
https://lists.sourceforge.net/lists/listinfo/itext-questions

©2008 junlu.com - Jax Systems, LLC, U.S.A.