Announcement Announcement Module
Collapse
No announcement yet.
iText Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • iText

    hello all,
    i have a view that works well for a time but after a hours begin to throws exception all the requests:

    the view is:
    Code:
    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
    	}
    }
    the exception:
    Code:
    [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(PdfIndirectObject.java(Compiled Code))
    	at com.lowagie.text.pdf.PdfWriter$PdfBody.add(PdfWriter.java(Compiled Code))
    	at com.lowagie.text.pdf.PdfWriter.addToBody(PdfWriter.java(Inlined Compiled Code))
    	at com.lowagie.text.pdf.PdfStamperImp.close(PdfStamperImp.java(Compiled Code))
    	at com.lowagie.text.pdf.PdfStamper.close(PdfStamper.java:185)
    	at iam.formularios.web.views.FormularioPdfView.pasteTemplateFormulario(FormularioPdfView.java:123)
    	at iam.formularios.web.views.FormularioPdfView.renderMergedOutputModel(FormularioPdfView.java:83)
    	at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)
    	at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:917)
    	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:696)
    	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:623)
    	at org.springframework.web.servlet.FrameworkServlet.serviceWrapper(FrameworkServlet.java:384)
    	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.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(StrictLifecycleServlet.java:167)
    	at com.ibm.servlet.engine.webapp.IdleServletState.service(StrictLifecycleServlet.java:297)
    	at com.ibm.servlet.engine.webapp.StrictLifecycleServlet.service(StrictLifecycleServlet.java:110)
    	at com.ibm.servlet.engine.webapp.ServletInstance.service(ServletManager.java:472)
    	at com.ibm.servlet.engine.webapp.ValidServletReferenceState.dispatch(ServletManager.java:1012)
    	at com.ibm.servlet.engine.webapp.ServletInstanceReference.dispatch(ServletManager.java:913)
    	at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:721)
    	at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:374)
    	at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:118)
    	at com.ibm.servlet.engine.srt.WebAppInvoker.doForward(WebAppInvoker.java:134)
    	at com.ibm.servlet.engine.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:239)
    	at com.ibm.servlet.engine.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:67)
    	at com.ibm.servlet.engine.invocation.CacheableInvocationContext.invoke(CacheableInvocationContext.java:106)
    	at com.ibm.servlet.engine.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:154)
    	at com.ibm.servlet.engine.oselistener.OSEListenerDispatcher.service(OSEListener.java:317)
    	at com.ibm.servlet.engine.http11.HttpConnection.handleRequest(HttpConnection.java:60)
    	at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.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.

  • #2
    Have you checked the iText source code? I would think that looking there would be a good starting point. It doesn't look to be anything Spring's doing from a quick glance at the stack trace. Does iText have forums or mailing lists?

    Comment


    • #3
      Mailing list: http://sourceforge.net/mailarchive/f...?forum_id=3273
      Home page: http://www.lowagie.com/iText/

      Have you tried using the latest release (out on may 11th)?

      Comment


      • #4
        thank you very much,

        i was using iText 1.1.4 (spring zip 1.5).
        i have upgrade iText version to 1.3, and works well.

        thanks,
        CÚsar.

        Comment


        • #5
          Excelent!

          Comment

          Working...
          X