Are you sure that you didn't exhaust somewhere the file handles? 

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On 
> Behalf Of Fernandez Garcia, Cesar
> Sent: Monday, May 09, 2005 1:42 PM
> To: itext-questions@lists.sourceforge.net
> Subject: [iText-questions] PdfStamper.close throw NullPointerException
> 
> hello all,
> i am using Spring and have a view that works well for a time 
> but after a
> hours begin to throws exception all the requests:
> 
> the view is:
> public class FormularioPdfView extends AbstractView {
>       
>       private static final int OUTPUT_BYTE_ARRAY_INITIAL_SIZE = 1024;
> 
>       public FormularioPdfView() {
>               setContentType("application/pdf");
>       }
>       
>       protected final void renderMergedOutputModel(Map model,
> HttpServletRequest request, HttpServletResponse response) 
> throws Exception {
> 
>               ByteArrayOutputStream byteFormulario = new
> ByteArrayOutputStream(OUTPUT_BYTE_ARRAY_INITIAL_SIZE);
>               
>               Map pdfFields = (Map)model.get("pdfFields");
>               byte[]  templateImpreso =
> (byte[])model.get("templateImpreso");
> 
>               pasteTemplateFormulario(pdfFields, templateImpreso,
> byteFormulario);
> 
>               // Write content type and also length 
> (determined via byte
> array).
>               response.setContentType(getContentType());
>               response.setHeader("Content-disposition", 
> "attachment" );
>               response.setContentLength(byteFormulario.size());
> 
>               // Flush byte array to servlet output stream.
>               ServletOutputStream out = response.getOutputStream();
>               byteFormulario.writeTo(out);
>               out.flush();
>       }
> 
>       private void pasteTemplateFormulario(Map fieldsForm, byte[]
> bImpreso, OutputStream byteFormulario) throws Exception 
>       {
>               PdfReader reader = new PdfReader(bImpreso);
> 
>               PdfStamper stamp = new PdfStamper(reader, 
> byteFormulario);
>               AcroFields acroFields = stamp.getAcroFields();
> 
>               Iterator entries = fieldsForm.entrySet().iterator();
>               while (entries.hasNext())
>               {
>                       Map.Entry entry = (Map.Entry)entries.next();
>                       String key = entry.getKey().toString();
>                       String value = (entry.getValue() != null ?
> entry.getValue().toString() : "");
>                       acroFields.setField(key, value);
>               }
>               stamp.close(); // throw NullPointerException
>       }
> }
> [/code]
> 
> the exception:
> 
> [9/05/05 13:50:28:691 CEST] 2c006234 WebGroup      X Servlet Error: :
> java.lang.NullPointerException
>       at 
> com.lowagie.text.pdf.PRStream.toPdf(PRStream.java(Compiled Code))
>       at
> com.lowagie.text.pdf.PdfIndirectObject.writeTo(PdfIndirectObje
> ct.java(Compil
> ed Code))
>       at
> com.lowagie.text.pdf.PdfWriter$PdfBody.add(PdfWriter.java(Comp
> iled Code))
>       at 
> com.lowagie.text.pdf.PdfWriter.addToBody(PdfWriter.java(Inlined
> Compiled Code))
>       at
> com.lowagie.text.pdf.PdfStamperImp.close(PdfStamperImp.java(Co
> mpiled Code))
>       at com.lowagie.text.pdf.PdfStamper.close(PdfStamper.java:185)
>       at
> iam.formularios.web.views.FormularioPdfView.pasteTemplateFormu
> lario(Formular
> ioPdfView.java:123)
>       at
> iam.formularios.web.views.FormularioPdfView.renderMergedOutput
> Model(Formular
> ioPdfView.java:83)
>       at
> org.springframework.web.servlet.view.AbstractView.render(Abstr
> actView.java:2
> 50)
>       at
> org.springframework.web.servlet.DispatcherServlet.render(Dispa
> tcherServlet.j
> ava:917)
>       at
> org.springframework.web.servlet.DispatcherServlet.doDispatch(D
> ispatcherServl
> et.java:696)
>       at
> org.springframework.web.servlet.DispatcherServlet.doService(Di
> spatcherServle
> t.java:623)
>       at
> org.springframework.web.servlet.FrameworkServlet.serviceWrappe
> r(FrameworkSer
> vlet.java:384)
>       at
> org.springframework.web.servlet.FrameworkServlet.doGet(Framewo
> rkServlet.java
> :344)
>       at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
>       at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
>       at
> com.ibm.servlet.engine.webapp.StrictServletInstance.doService(
> ServletManager
> .java:827)
>       at
> com.ibm.servlet.engine.webapp.StrictLifecycleServlet._service(
> StrictLifecycl
> eServlet.java:167)
>       at
> com.ibm.servlet.engine.webapp.IdleServletState.service(StrictL
> ifecycleServle
> t.java:297)
>       at
> com.ibm.servlet.engine.webapp.StrictLifecycleServlet.service(S
> trictLifecycle
> Servlet.java:110)
>       at
> com.ibm.servlet.engine.webapp.ServletInstance.service(ServletM
> anager.java:47
> 2)
>       at
> com.ibm.servlet.engine.webapp.ValidServletReferenceState.dispa
> tch(ServletMan
> ager.java:1012)
>       at
> com.ibm.servlet.engine.webapp.ServletInstanceReference.dispatc
> h(ServletManag
> er.java:913)
>       at
> com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.handleWe
> bAppDispatch(W
> ebAppRequestDispatcher.java:721)
>       at
> com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.dispatch
> (WebAppRequest
> Dispatcher.java:374)
>       at
> com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.forward(
> WebAppRequestD
> ispatcher.java:118)
>       at
> com.ibm.servlet.engine.srt.WebAppInvoker.doForward(WebAppInvok
> er.java:134)
>       at
> com.ibm.servlet.engine.srt.WebAppInvoker.handleInvocationHook(
> WebAppInvoker.
> java:239)
>       at
> com.ibm.servlet.engine.invocation.CachedInvocation.handleInvoc
> ation(CachedIn
> vocation.java:67)
>       at
> com.ibm.servlet.engine.invocation.CacheableInvocationContext.i
> nvoke(Cacheabl
> eInvocationContext.java:106)
>       at
> com.ibm.servlet.engine.srp.ServletRequestProcessor.dispatchByU
> RI(ServletRequ
> estProcessor.java:154)
>       at
> com.ibm.servlet.engine.oselistener.OSEListenerDispatcher.servi
> ce(OSEListener
> .java:317)
>       at
> com.ibm.servlet.engine.http11.HttpConnection.handleRequest(Htt
> pConnection.ja
> va:60)
>       at
> com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnec
> tion.java:477)
>       at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:351)
>       at 
> com.ibm.ws.util.CachedThread.run(ThreadPool.java(Compiled Code))
> anyone what happen???
> 
> thanks in advance,
>    César.
> 
> 
> -------------------------------------------------------
> This SF.Net email is sponsored by: NEC IT Guy Games.
> Get your fingers limbered up and give it your best shot. 4 
> great events, 4
> opportunities to win big! Highest score wins.NEC IT Guy Games. Play to
> win an NEC 61 plasma display. Visit http://www.necitguy.com/?r=20
> _______________________________________________
> iText-questions mailing list
> iText-questions@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/itext-questions
> 


-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games.
Get your fingers limbered up and give it your best shot. 4 great events, 4
opportunities to win big! Highest score wins.NEC IT Guy Games. Play to
win an NEC 61 plasma display. Visit http://www.necitguy.com/?r 
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to