4 Replies Latest reply on Mar 27, 2012 10:13 PM by Rohit Kamboj

    Seam Excel JBoss 5.1 problem

    Anderson Freitas Newbie

      Hi all,


      I'm having a problem with Seam Excel, running it under JBoss 5.1 and Seam 2.2.1.Final


      In the attribute templateURI I refer to the file /xls/template.xls but when I run the page it returns me the following error:


      16:33:21,922 ERROR [viewhandler] Error Rendering View[/secure/reports/report.xhtml]
      org.jboss.seam.excel.ExcelWorkbookException: Could not create workbook
      ...
      Caused by: java.lang.NullPointerException
              at jxl.read.biff.File.<init>(File.java:91)
              at jxl.Workbook.getWorkbook(Workbook.java:268)
              at jxl.Workbook.getWorkbook(Workbook.java:253)
              at org.jboss.seam.excel.jxl.JXLExcelWorkbook.createWorkbook(JXLExcelWorkbook.java:360)
              ... 55 more


      See the report.xhtml block below:



      <e:workbook  templateURI="/xls/template.xls" filename="result.xls">
              <e:worksheet value="#{reportCriteria}" 
                      var="each" name="Patient Episode Totals" startRow="2" startColumn="2" sheetProtected="true">
                      <e:column >
                              <e:cell value="#{each}"/>
                      </e:column>               
              </e:worksheet>
      




      See the web.xml bellow:



      <?xml version="1.0" encoding="UTF-8"?>
      <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
              xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
              version="2.5">
              <context-param>
                      <param-name>org.richfaces.SKIN</param-name>
                      <param-value>test</param-value>
              </context-param>
              <context-param>
                      <param-name>org.richfaces.CONTROL_SKINNING_CLASSES</param-name>
                      <param-value>enable</param-value>
              </context-param>
              <context-param>
                      <param-name>facelets.REFRESH_PERIOD</param-name>
                      <param-value>2</param-value>
              </context-param>
              <filter>
                      <filter-name>Seam Filter</filter-name>
                      <filter-class>org.jboss.seam.servlet.SeamFilter</filter-class>
              </filter>
              <listener>
                      <listener-class>org.jboss.seam.servlet.SeamListener</listener-class>
              </listener>
              <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.SeamResourceServlet</servlet-class>
              </servlet>
              <servlet-mapping>
                      <servlet-name>Seam Resource Servlet</servlet-name>
                      <url-pattern>/seam/resource/*</url-pattern>
              </servlet-mapping>
              <context-param>
                      <param-name>facelets.DEVELOPMENT</param-name>
                      <param-value>true</param-value>
              </context-param>
              <context-param>
                      <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
                      <param-value>.xhtml</param-value>
              </context-param>
              <servlet>
                      <servlet-name>Faces Servlet</servlet-name>
                      <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
                      <load-on-startup>1</load-on-startup>
              </servlet>
              <servlet-mapping>
                      <servlet-name>Faces Servlet</servlet-name>
                      <url-pattern>*.seam</url-pattern>
              </servlet-mapping>
              <servlet>
                      <servlet-name>Document Store Servlet</servlet-name>
                      <servlet-class>org.jboss.seam.document.DocumentStoreServlet</servlet-class>
              </servlet>
              <servlet-mapping>
                      <servlet-name>Document Store Servlet</servlet-name>
                      <url-pattern>*.csv</url-pattern>
              </servlet-mapping>
              <servlet-mapping>
                      <servlet-name>Document Store Servlet</servlet-name>
                      <url-pattern>*.pdf</url-pattern>
              </servlet-mapping>
              <servlet-mapping>
                      <servlet-name>Document Store Servlet</servlet-name>
                      <url-pattern>*.xls</url-pattern>
              </servlet-mapping>
              <servlet>
                      <servlet-name>ImportService</servlet-name>
                      <servlet-class>com.test.ws.ImportService</servlet-class>
              </servlet>
              <servlet-mapping>
                      <servlet-name>ImportService</servlet-name>
                      <url-pattern>/importservice/*</url-pattern>
              </servlet-mapping>
              <context-param>
                      <param-name>webAppRootKey</param-name>
                      <param-value>test</param-value>
              </context-param>
              <security-constraint>
                      <display-name>Restrict raw XHTML Documents</display-name>
                      <web-resource-collection>
                              <web-resource-name>XHTML</web-resource-name>
                              <url-pattern>*.xhtml</url-pattern>
                      </web-resource-collection>
                      <auth-constraint />
              </security-constraint>
              <session-config>
                      <session-timeout>30</session-timeout>
              </session-config>
      </web-app>
      





      See jboss.xml below:



       <!DOCTYPE jboss-web PUBLIC
          "-//JBoss//DTD Web Application 4.2//EN"
          "http://www.jboss.org/j2ee/dtd/jboss-web_4_2.dtd">
      
      <jboss-web>  
          <class-loading java2ClassLoadingCompliance="false">
              <loader-repository>
                  seam.jboss.org:loader=auscr
                  <loader-repository-config>java2ParentDelegation=false</loader-repository-config>
              </loader-repository>
          </class-loading>
          <context-root>auscr</context-root>
      </jboss-web>
      




      My application follows the following structure:
      - webapp
              - META-INF
              - secure
                      - reports
                              . report.xhtml
              - WEB-INF
                      - classes
                              lots of java classes
                      - lib
                      . components.xml
                      . faces-config.xml
                      . jboss-web.xml
                      . pages.xml
                      . web.xml
              - xls
                      . template.xml


      When I copy the XLS file to /webapp/WEB-INF/classes it DOES work, so I suspect it is some class loading issue, but I couldn't find any relevant documentation that could help me.


      This application was running previously on JBoss 4.2 and I never had a problem, but after migrating it to JBoss 5.1 the hell began.


      Does someone have a clue about what is going on?


      Thanks,
      Anderson

        • 1. Re: Seam Excel JBoss 5.1 problem
          Anderson Freitas Newbie

          This should be my application structure mentioned above:




          - webapp
               - META-INF
               - secure
                    - reports
                         . report.xhtml
               - WEB-INF
                    - classes
                         lots of java classes
                    - lib
                    . components.xml
                    . faces-config.xml
                    . jboss-web.xml
                    . pages.xml
                    . web.xml
               - xls
                    . template.xml
          



          • 2. Re: Seam Excel JBoss 5.1 problem
            Rohit Kamboj Newbie

            Hi,

             

            Did you get any solution on this? I am stuck with the same problem. I am referring to the stylesheet in my workbook as:

             

            <e:link URL="#{request.contextPath}/stylesheet/myexcel.css"/>

             

            This works perfectly on JBoss 4.3 but I am getting the following exception on JBoss 5.1 (Seam 2.2.2 EAP):

             

            Caused by: java.lang.NullPointerException

                      at java.io.Reader.<init>(Reader.java:61)

                      at java.io.InputStreamReader.<init>(InputStreamReader.java:55)

                      at org.jboss.seam.excel.css.CSSParser.readCSS(CSSParser.java:149)

                      at org.jboss.seam.excel.css.CSSParser.parseStylesheet(CSSParser.java:178)

                      at org.jboss.seam.excel.css.CSSParser.loadStylesheets(CSSParser.java:90)

                      at org.jboss.seam.excel.css.CSSParser.setStylesheets(CSSParser.java:366)

                      at org.jboss.seam.excel.jxl.JXLHelper.setStylesheets(JXLHelper.java:285)

                      at org.jboss.seam.excel.jxl.JXLExcelWorkbook.setStylesheets(JXLExcelWorkbook.java:702)

            • 3. Re: Seam Excel JBoss 5.1 problem
              Anderson Freitas Newbie

              Hi Rohit,

               

              I ended up having to put my excel templates in the classpath. I don't really know if this is a limitation of JBoss 5.1 or Seam 2.2.x (most likely to be Seam's fault).

               

              So now my project looks like this:

               

              - webapp

                      - META-INF

                      - secure

                              - reports

                                      . report.xhtml

                      - WEB-INF

                              - classes

                                      lots of java classes

                                 TEMPLATES (xls files)

                              - lib

                              . components.xml

                              . faces-config.xml

                              . jboss-web.xml

                              . pages.xml

                              . web.xml

               

              Let me know if you manage to solve this problem.

              • 4. Re: Seam Excel JBoss 5.1 problem
                Rohit Kamboj Newbie

                Thanks Anderson.

                After putting the templates under WEB-INF/classes, what path did you use to refer them? /template.xml???

                My exact problem is described here (https://community.jboss.org/message/726752#726752) in point #2.