Bang on the money,
  I hadn't realised that each servlet was instantiated only once.  Rather than force the server to create multiple instances I removed the class variables and that fixed it.
 
 
Regards
 
Peter Wilkinson
System Developer
Mantel Solutions Pty Ltd
 
PO Box 98, 35 Hamilton Road
Moorooka QLD 4105
 
P: +61 7 3848 0001
F: +61 7 3392 9923
 
The information contained in this electronic message (e-mail) and any files transmitted with it, is intended for the named recipients only.  It may contain privileged and or confidential information and if you are not the intended recipient you must not copy distribute or take any action in reliance on it. If you have received this electronic message (e-mail) and any files transmitted with it in error please delete immediately and advise Mantel Solutions on 07 3848 0001.
----------------------- Original Message -----------------------
  
From: "Paulo Soares" <[EMAIL PROTECTED]>
To: "Post all your questions about iText here" <[email protected]>
Date: Thu, 20 Jul 2006 09:01:06 +0100
Subject: Re: [iText-questions] IText doesn't seem to be thread safe?
  
I suspect that it's a problem with the server configuration. The app server
can work in two modes: one where each request creates a new instance of the
servlet and another where the same instance is used by all the requests.
Your server is configured for the latter. Just guessing.

Paulo

----- Original Message -----
From: "Peter Wilkinson" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Thursday, July 20, 2006 4:36 AM
Subject: [iText-questions] IText doesn't seem to be thread safe?


> I've written a jsp page that produces a PDF using iText and it work great
> until 2 people try and run the report at the same time.
>
> I get a variety of errors including
>
>  DocumentException : Document is closed.
>  ConcurrentModficationException
>  NullPointerException
>
> as well as pdf's that are corrupt.
>
> I haven't declared a single thing on the page as being static.  All the
> exceptions are generated when trying to call a Document method so I'm
> wondering if maybe the document object isn't thread safe?
>
> This is my document creation code.
>
> document = new Document(PageSize.A4.rotate());
> baseFont = BaseFont.createFont("Helvetica", BaseFont.WINANSI, false);
> font = new Font(baseFont, defaultFontSize);
> totalFont = new Font(baseFont, 9);
> totalFont.setStyle(Font.BOLD);
> heading1Font = new Font(baseFont, 20, Font.BOLDITALIC, new Color(0, 0,
> 0));
> heading2Font = new Font(baseFont, 17, Font.BOLDITALIC, new Color(0, 0,
> 0));
> heading3Font = new Font(baseFont, 14, Font.BOLDITALIC, new Color(0, 0,
> 0));
> defaultLayoutCell = new Cell();
> defaultLayoutCell.setBorder(Rectangle.NO_BORDER);
> ByteArrayOutputStream baos = new ByteArrayOutputStream();
> writer = PdfWriter.getInstance(document, baos);
> //writer.setEncryption(false, "", "", PdfWriter.AllowCopy |
> PdfWriter.AllowPrinting);
> PageEventHandler pageEventHandler = new PageEventHandler();
> writer.setPageEvent(pageEventHandler);
> writer.setViewerPreferences(PdfWriter.PageModeUseOutlines);
> // step 3: we open the document
> document.open();
>
> Regards
>
> Peter Wilkinson
> System Developer
> Mantel Solutions Pty Ltd
>
> PO Box 98, 35 Hamilton Road
> Moorooka QLD 4105
>
> P: +61 7 3848 0001
> F: +61 7 3392 9923
> W: www.mantel.com.au
>
> The information contained in this electronic message (e-mail) and any
> files transmitted with it, is intended for the named recipients only.  It
> may contain privileged and or confidential information and if you are not
> the intended recipient you must not copy distribute or take any action in
> reliance on it. If you have received this electronic message (e-mail) and
> any files transmitted with it in error please delete immediately and
> advise Mantel Solutions on 07 3848 0001.


--------------------------------------------------------------------------------


> -------------------------------------------------------------------------
> 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
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/itext-questions
>


-------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions



-------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to