4 Replies Latest reply on Mar 24, 2007 10:22 AM by Prem Kosta

    Help: Seam PDF NPE??

    Prem Kosta Newbie

      Hi.,
      I just followed seam itext example to create and render a PDF page but unfortunately NPE.

      I just have a form with s:link like

      <h:form id="testFileDownload" >
       <s:link view="/lists.xhtml" value="Test List" />
      </h:form>
      



      Please see below for stack trace:

      18:04:04,486 ERROR [PhaseListenerManager] Exception in PhaseListener RENDER_RESPONSE(6) beforePhase.
      java.lang.NullPointerException
       at org.jboss.seam.pdf.DocumentStorePhaseListener.sendContent(DocumentStorePhaseListener.java:45)
       at org.jboss.seam.pdf.DocumentStorePhaseListener.beforePhase(DocumentStorePhaseListener.java:37)
       at org.apache.myfaces.lifecycle.PhaseListenerManager.informPhaseListenersBefore(PhaseListenerManager.java:73)
       at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:126)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:140)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:97)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:75)
       at org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:213)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:144)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:63)
       at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
       at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
       at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:57)
       at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
       at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:79)
       at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
       at org.jboss.seam.web.SeamFilter.doFilter(SeamFilter.java:84)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
       at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
       at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
       at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
       at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
       at java.lang.Thread.run(Thread.java:595)
      


      Envirnoment: Seam 1.1.6 GA; Facelets; Ajax4Jsf_1.0; Myfaces 1.1.5; Tomahawk 1.1.3

      Any help would be appreciated.

      Thanks

        • 1. Re: Help: Seam PDF NPE??
          Norman Richards Master

          What does your document look like?

          • 2. Re: Help: Seam PDF NPE??
            Prem Kosta Newbie

            Hi.,
            Thanks for ur response.


            What does your document look like?


            Actually first i tried the lists.xhtml (with binding) from itext example but then I thought that might be a problem, so i removed all tags and just left some some static elements like this

            <p:document xmlns:ui="http://java.sun.com/jsf/facelets"
             xmlns:s="http://jboss.com/products/seam/taglib"
             xmlns:p="http://jboss.com/products/seam/pdf">
             <p:font size="24">
             <p:paragraph spacingAfter="50">List examples</p:paragraph>
             </p:font>
             <p:paragraph>Basic list:</p:paragraph>
            </p:document>
            


            I think its something to do with configuration becos whatever the elements (static/dynamic), it throws the same error.

            If you like i could also send my web.xml file.

            Please note that I'm using Tomcat with embedded microcontainer.

            Thanks

            • 3. Re: Help: Seam PDF NPE??
              Norman Richards Master

              That document is fine. I'd guess you have a configuration error. Are you able to use the document servlet like the itext example does?

              • 4. Re: Help: Seam PDF NPE??
                Prem Kosta Newbie

                Hi.,
                I debugged inside Seam code and found that in DocumentStorePhaseListener documentData is NULL

                 DocumentData documentData = DocumentStore.instance).getDocumentData(contentId);
                 byte[] data = documentData.getData();
                



                Here's my web.xml file

                <?xml version="1.0" encoding="UTF-8"?>
                <web-app>
                
                 <context-param>
                 <param-name>javax.faces.CONFIG_FILES</param-name>
                 <param-value>/WEB-INF/navigation.xml</param-value>
                 </context-param>
                
                 <!-- Ajax4jsf (must come first!) -->
                 <filter>
                 <display-name>Ajax4jsf Filter</display-name>
                 <filter-name>ajax4jsf</filter-name>
                 <filter-class>org.ajax4jsf.Filter</filter-class>
                 </filter>
                 <filter-mapping>
                 <filter-name>ajax4jsf</filter-name>
                 <servlet-name>Faces Servlet</servlet-name>
                 <dispatcher>REQUEST</dispatcher>
                 <dispatcher>FORWARD</dispatcher>
                 <dispatcher>INCLUDE</dispatcher>
                 </filter-mapping>
                 <context-param>
                 <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
                 <param-value>org.jboss.seam.ui.facelet.SeamFaceletViewHandler</param-value>
                 </context-param>
                
                 <!-- Seam -->
                 <listener>
                 <listener-class>org.jboss.seam.servlet.SeamListener</listener-class>
                 </listener>
                <!-- -->
                 <filter>
                 <filter-name>Seam Filter</filter-name>
                 <filter-class>org.jboss.seam.web.SeamFilter</filter-class>
                 </filter>
                
                 <filter-mapping>
                 <filter-name>Seam Filter</filter-name>
                 <url-pattern>/*</url-pattern>
                 </filter-mapping>
                
                
                
                 <servlet>
                 <servlet-name>Seam Resource Servlet</servlet-name>
                 <servlet-class>org.jboss.seam.servlet.ResourceServlet</servlet-class>
                 </servlet>
                
                 <servlet-mapping>
                 <servlet-name>Seam Resource Servlet</servlet-name>
                 <url-pattern>/seam/resource/*</url-pattern>
                 </servlet-mapping>
                
                
                 <!-- Faces Servlet -->
                 <servlet>
                 <servlet-name>Faces Servlet</servlet-name>
                 <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
                 <load-on-startup>1</load-on-startup>
                 </servlet>
                 <!-- Faces Servlet Mapping -->
                 <servlet-mapping>
                 <servlet-name>Faces Servlet</servlet-name>
                 <url-pattern>*.seam</url-pattern>
                 </servlet-mapping>
                 <!-- SEAM PDF -->
                
                 <filter>
                 <filter-name>Seam Servlet Filter</filter-name>
                 <filter-class>org.jboss.seam.servlet.SeamServletFilter</filter-class>
                 </filter>
                
                 <filter-mapping>
                 <filter-name>Seam Servlet Filter</filter-name>
                 <url-pattern>*.pdf</url-pattern>
                 </filter-mapping>
                
                 <filter>
                 <filter-name>Seam Redirect Filter</filter-name>
                 <filter-class>org.jboss.seam.servlet.SeamRedirectFilter</filter-class>
                 </filter>
                
                 <filter-mapping>
                 <filter-name>Seam Redirect Filter</filter-name>
                 <url-pattern>*.seam</url-pattern>
                 </filter-mapping>
                
                
                
                 <servlet>
                 <servlet-name>Document Store Servlet</servlet-name>
                 <servlet-class>org.jboss.seam.pdf.DocumentStoreServlet</servlet-class>
                 </servlet>
                
                 <servlet-mapping>
                 <servlet-name>Document Store Servlet</servlet-name>
                 <url-pattern>*.pdf</url-pattern>
                 </servlet-mapping>
                
                 <!-- JSF parameters -->
                 <context-param>
                 <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
                 <param-value>client</param-value>
                 </context-param>
                 <context-param>
                 <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
                 <param-value>.xhtml</param-value>
                 </context-param>
                 <context-param>
                 <param-name>facelets.DEVELOPMENT</param-name>
                 <param-value>true</param-value>
                 </context-param>
                
                 <welcome-file-list>
                 <welcome-file>index.jsp</welcome-file>
                 </welcome-file-list>
                
                 <!-- MyFaces -->
                 <listener>
                 <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
                 </listener>
                
                
                 <!-- For Tomahawk -->
                 <context-param>
                 <param-name>facelets.LIBRARIES</param-name>
                 <param-value>/WEB-INF/tomahawk.taglib.xml</param-value>
                 </context-param>
                
                
                 <!-- Extensions Filter -->
                 <filter>
                 <filter-name>MyFacesExtensionsFilter</filter-name>
                 <filter-class>
                 org.apache.myfaces.webapp.filter.ExtensionsFilter
                 </filter-class>
                 <init-param>
                 <param-name>maxFileSize</param-name>
                 <param-value>20m</param-value>
                 </init-param>
                 </filter>
                
                
                 <filter-mapping>
                 <filter-name>MyFacesExtensionsFilter</filter-name>
                 <servlet-name>Faces Servlet</servlet-name>
                 </filter-mapping>
                
                
                
                 <!-- extension mapping for serving page-independent resources (javascript, stylesheets, images, etc.) -->
                 <filter-mapping>
                 <filter-name>MyFacesExtensionsFilter</filter-name>
                 <url-pattern>/seam/myFacesExtensionResource/*</url-pattern>
                 </filter-mapping>
                
                
                 <filter-mapping>
                 <filter-name>MyFacesExtensionsFilter</filter-name>
                 <url-pattern>*.seam</url-pattern>
                 </filter-mapping>
                
                 <!--
                 <context-param>
                 <param-name>org.apache.myfaces.DETECT_JAVASCRIPT</param-name>
                 <param-value>true</param-value>
                 </context-param>
                 -->
                
                
                 <context-param>
                 <description>
                 If true, rendered HTML code will be formatted, so that it is
                 "human readable". i.e. additional line separators and
                 whitespace will be written, that do not influence the HTML
                 code. Default: "true"
                 </description>
                 <param-name>org.apache.myfaces.PRETTY_HTML</param-name>
                 <param-value>true</param-value>
                 </context-param>
                
                </web-app>
                


                In previous project we used JasperReports and now we want to use all features of SEAM. I don't want to go back to jasperreports. I think its just a silly config problem.

                Please help me.

                Thanks