Writing documents to files on server-side

Writing documents to files on server-side

Forum member · Sep 19, 2007
I am developing a server application that prints PDF files to an archive folder on the server: try { File f = new File(pdfFilename); if( f.exists() ) { f.delete(); } document.draw(pdfFilename); File pdfFile = new File(pdfFilename); if( ! pdfFile.exists() ) { throw new Exception("No file"); } } catch (com.cete.dynamicpdf.GeneratorException e) { log.error("Error saving PDF chart", e); } catch (Throwable t) { log.error("Error printing to file", t); } I just moved this to be accessible from a servlet and during load testing noticed that when multiple users hit my server we are getting cases where the PDF file does not exist after the document.draw() call. I had 6 people hit my test server at the same time and we had 1 or 2 instances of the PDF not printing during each test. The only thing I can think of is thread-safety of the Document class?

Re: Writing documents to files on server-side

Support · Sep 19, 2007
Hello, The object model is designed to support multithreaded environment. Multiple threads can generate PDF documents at the same time. We have done testing in multi threaded environment and not experienced any problems. Can you please send us over the source code you are using to our [^a|mailto:support@cete.com|Support Team ^], so that they can take a look at it? Also please make sure that you are using the latest build JAR files. If you currently have a license, you can download the latest licensed copy of JAR files from the Customer Area . Thanks, ceTe Software Support Team

Re: Writing documents to files on server-side

Forum member · Sep 19, 2007
Thanks for the quick response. I discovered a problem in my code (good old static variables) that was the likely culprit. So my code was not thread-safe. thanks again