2 Replies Latest reply on Sep 12, 2008 9:43 AM by Hans Schlegel

    Need help with iText PDF

    Matt Galloway Newbie
      I've spent the last couple of hours trying to get a PDF out of Seam.

      I'm using Seam 2.0.1GA on JBoss 4.2.2GA.

      I have updated components.xml (currently I am not setting use-extensions to "true" just to minimize moving parts.)

      I have the libraries in the right place I think.  And I have a super simple document that look likes this (I started with more complex content but simplified for debuging):

      <p:document xmlns="http://www.w3.org/1999/xhtml"
           xmlns:p="http://jboss.com/products/seam/pdf"
           xmlns:ui="http://java.sun.com/jsf/facelets"
           xmlns:s="http://jboss.com/products/seam/taglib"
           title="PDF Recipe"
           creator="Matt Galloway"
           pageSize="LETTER">
           
           Hello, world!

      </p:document>

      As soon as I try to hit the page I get the following error:

      17:05:54,255 WARN  [lifecycle] phase(RENDER_RESPONSE 6,com.sun.faces.context.FacesContextImpl@a230bb) threw exception: java.lang.NullPointerException null
      org.jboss.seam.pdf.DocumentStorePhaseListener.sendContent(DocumentStorePhaseListener.java:47)
      org.jboss.seam.pdf.DocumentStorePhaseListener.beforePhase(DocumentStorePhaseListener.java:37)
      com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:222)
      com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
      javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
      org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:147)
      org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:276)
      org.ajax4jsf.Filter.doFilter(Filter.java:175)
      org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
      org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
      org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
      org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
      org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
      org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
      org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
      org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
      org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
      org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
      org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
      java.lang.Thread.run(Thread.java:613)

      17:05:54,288 WARN  [lifecycle] phase(RENDER_RESPONSE 6,com.sun.faces.context.FacesContextImpl@d1f907) threw exception: java.lang.NullPointerException null
      org.jboss.seam.pdf.DocumentStorePhaseListener.sendContent(DocumentStorePhaseListener.java:47)
      org.jboss.seam.pdf.DocumentStorePhaseListener.beforePhase(DocumentStorePhaseListener.java:37)
      com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:222)
      com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
      javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
      org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:147)
      org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:276)
      org.ajax4jsf.Filter.doFilter(Filter.java:175)
      org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
      org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
      org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
      org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
      org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
      org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
      org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
      org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
      org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
      org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
      org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
      java.lang.Thread.run(Thread.java:613)

      In the browser I see:

      HTTP Status 404 - /TR2/seam-doc.seam

      type Status report

      message /TR2/seam-doc.seam

      description The requested resource (/TR2/seam-doc.seam) is not available.

      JBossWeb/2.0.1.GA


      If I remove the "Hello, world!" from my page I get an error that says there are no pages so I know it's trying to create the PDF.

      There is another mention of this same error here: http://seamframework.org/Community/AccessingPDFForTheFirstTimeCauses404

      But in that case if the user hits the same page again it works... not so for me.

      I've tried everything I can think of, any suggestions would be appreciated.

      Thanks in advance,

      Matt



        • 1. Re: Need help with iText PDF
          Matt Galloway Newbie

          I've tried JBoss 4.2.3 (for JVM 5) with both Apple JDK 5 AND 6 and got the same results.


          I also tried the iText example on JBoss 4.2.3 using the latest stable Seam distro (2.0.2.SP1) and it didn't work.


          I'm thinking there is an issue with Apple and iText PDF generation.


          Any thoughts?


          -Matt

          • 2. Re: Need help with iText PDF
            Hans Schlegel Newbie

            Hi Matt


            I think that you need to put everything in p-tags.....



            <p:document xmlns="http://www.w3.org/1999/xhtml"
             xmlns:p="http://jboss.com/products/seam/pdf"
             xmlns:ui="http://java.sun.com/jsf/facelets"
             xmlns:s="http://jboss.com/products/seam/taglib"
             title="PDF Recipe"
             creator="Matt Galloway"
             pageSize="LETTER">
            
            <p:font name="helvetica" style="normal" size="9">
               Hello, world!
            </p:font>
            
            </p:document>