1 Reply Latest reply on Oct 25, 2011 1:00 PM by j0sh

    JSF2 + Richfaces 4 + Apache Trinidad 2 Error on Ajax Requests

    evefuji

      Sorry for my bad english, I'm brazilian.

       

      I have a project with JSF2 + Richfaces 4 Final + Apache Trinidad 2 and works good, except ajax requests of richfaces components.

       

      Running over Glassfish v3.1.

       

      I think it's ViewHandler Trinidad Richfaces the blocking, but I can not solve.Follow my web.xml and faces-config.xml.

       

      Below the file's contents give an example of what happens:

       

       

      web.xml:

      <?xml version="1.0" encoding="UTF-8"?>

      <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">

          <context-param>

              <param-name>contextConfigLocation</param-name>

              <param-value>/WEB-INF/applicationContext.xml</param-value>

          </context-param>

          <context-param>

              <param-name>javax.faces.PROJECT_STAGE</param-name>

              <param-value>Development</param-value>

          </context-param>

          <context-param> 

              <param-name>javax.faces.STATE_SAVING_METHOD</param-name> 

              <param-value>client</param-value> 

          </context-param> 

          <context-param>

              <param-name>javax.faces.FACELETS_REFRESH_PERIOD</param-name>

              <param-value>1650</param-value>

          </context-param>

       

          <context-param>

              <param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>

              <param-value>true</param-value>

          </context-param>

       

          <context-param>

              <param-name>com.sun.faces.clientStateTimeout</param-name>

              <param-value>3600</param-value>

          </context-param>

       

          <context-param>

              <param-name>com.sun.faces.serializeServerState</param-name>

              <param-value>true</param-value>

          </context-param>

       

          <!-- To enable encryption -->

          <context-param>

              <param-name>org.apache.myfaces.USE_ENCRYPTION</param-name>

              <param-value>true</param-value>

           </context-param>

       

               <!-- Indicate the encryption algorithm used for encrypt the view state. -->

          <context-param>

              <param-name>org.apache.myfaces.ALGORITHM</param-name>

              <!-- See http://java.sun.com/j2se/1.4.2/docs/guide/security/jce/JCERefGuide.html for details -->

              <param-value>AES</param-value>

          </context-param>

       

       

          <!-- Defines the default mode and padding used for the encryption algorithm -->

          <context-param>

              <param-name>org.apache.myfaces.ALGORITHM.PARAMETERS</param-name>

              <param-value>CBC/PKCS5Padding</param-value>

          </context-param>

       

       

          <!-- Defines the initialization vector (Base64 encoded) used for the

               encryption algorithm. Note its usage depends on the algorithm config used,

               that means it must be defined if CBC mode is used and could not if ECB mode is used -->

          <context-param>

              <param-name>org.apache.myfaces.ALGORITHM.IV</param-name>

              <param-value>NzY1NDMyMTA3NjU0MzIxMA==</param-value>

          </context-param>

       

       

          <!-- Indicate the algorithm used to calculate the Message Authentication Code that is added to the view state. -->

          <context-param>

              <param-name>org.apache.myfaces.MAC_ALGORITHM</param-name>

              <param-value>HmacSHA1</param-value>

           </context-param>

          <context-param>

            <description>

             Use this context parameter to enable compression in MyFaces version 1.1.4 and later.

            </description>

            <param-name>org.apache.myfaces.COMPRESS_STATE_IN_CLIENT</param-name>

            <param-value>true</param-value>

          </context-param>

          <!-- Plugging the "Blue Sky" skin into the project -->

       

       

          <context-param>

             <param-name>org.richfaces.SKIN</param-name>

             <param-value>blueSky</param-value>

          </context-param>

       

       

          <!-- Making the RichFaces skin spread to standard HTML controls -->

       

       

          <context-param>

                <param-name>org.richfaces.CONTROL_SKINNING</param-name>

                <param-value>disable</param-value>

          </context-param>

       

          <context-param>

              <!--Unfortunately, Facelets provides no hook for plugging the PageResolver into the logic

                handling "facelets.VIEW_MAPPINGS". You should leave "facelets.VIEW_MAPPINGS"

                unset and use "org.apache.myfaces.trinidad.FACELETS_VIEW_MAPPINGS" instead.-->

            <param-name>org.apache.myfaces.trinidad.FACELETS_VIEW_MAPPINGS</param-name>

            <param-value>*.xhtml</param-value>

          </context-param>

       

          <context-param>

            <param-name>org.apache.myfaces.trinidadinternal.PPR_OVER_JSF_AJAX</param-name>

            <param-value>false</param-value>

          </context-param>

       

            <context-param>

              <param-name>org.apache.myfaces.SECRET</param-name>

              <param-value>MDEyMzQ1NjM4OTAxMjM0NTY3ODkwMTIz</param-value>

          </context-param>

          <context-param>

              <param-name>org.apache.myfaces.ALGORITHM</param-name>

              <param-value>AES</param-value>

          </context-param>

          <context-param>

              <param-name>org.apache.myfaces.ALGORITHM.PARAMETERS</param-name>

              <param-value>CBC/PKCS5Padding</param-value>

          </context-param>

          <context-param>

              <param-name>org.apache.myfaces.ALGORITHM.IV</param-name>

              <param-value>NzY1NDMyMTA3MzU0MzIxMA==</param-value>

          </context-param>

       

       

          <context-param>

              <!-- Maximum disk space per request (in bytes) -->

              <param-name>org.apache.myfaces.trinidad.UPLOAD_MAX_DISK_SPACE</param-name>

              <!-- Use 4GB -->

              <param-value>4294967296</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>

       

       

       

       

          <filter>

              <filter-name>CharacterEncodingFilter</filter-name>

              <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>

          </filter>

          <filter-mapping>

              <filter-name>CharacterEncodingFilter</filter-name>

              <servlet-name>Faces Servlet</servlet-name>

          </filter-mapping>

       

       

          <filter>

            <filter-name>SecurityFilter</filter-name>

            <filter-class>br.com.radio.demais.facade.util.SecurityFilter</filter-class>

          </filter>

       

          <filter-mapping>

            <filter-name>SecurityFilter</filter-name>

            <servlet-name>Faces Servlet</servlet-name>

            <url-pattern>/admin/*</url-pattern>

          </filter-mapping>

       

       

          <filter>

            <filter-name>trinidad</filter-name>

            <filter-class>org.apache.myfaces.trinidad.webapp.TrinidadFilter</filter-class>

          </filter>

       

       

          <filter-mapping>

            <filter-name>trinidad</filter-name>

            <servlet-name>Faces Servlet</servlet-name>

          </filter-mapping>

       

       

       

          <listener>

              <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>

          </listener>

          <servlet>

              <servlet-name>dispatcher</servlet-name>

              <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>

              <load-on-startup>2</load-on-startup>

          </servlet>

          <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>*.html</url-pattern>

          </servlet-mapping>

       

          <servlet>

            <servlet-name>resources</servlet-name>

            <servlet-class>org.apache.myfaces.trinidad.webapp.ResourceServlet</servlet-class>

          </servlet>

       

       

          <servlet-mapping>

            <servlet-name>resources</servlet-name>

            <url-pattern>/adf/*</url-pattern>

          </servlet-mapping>

       

       

       

          <session-config>

              <session-timeout>

                  30

              </session-timeout>

          </session-config>

          <welcome-file-list>

              <welcome-file>index.html</welcome-file>

          </welcome-file-list>

      </web-app>

       

       

      Faces-config.xml

       

      <?xml version='1.0' encoding='UTF-8'?>

       

       

      <!-- =========== FULL CONFIGURATION FILE ================================== -->

       

       

      <faces-config version="2.0"

          xmlns="http://java.sun.com/xml/ns/javaee"

          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

          xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd">

          <application>

              <resource-bundle>

                  <base-name>/Bundle</base-name>

                  <var>bundle</var>

              </resource-bundle>

              <default-render-kit-id>

                org.apache.myfaces.trinidad.core

              </default-render-kit-id>

              <el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver> 

          </application>

      </faces-config>

       

      A example:

       

      I put a progressBar in a page, and monitoring in server, the requests has made. But, the component not has been rendered, and when I press F5 key, the component has been rendered correctly.

       

      I monitoring with network inspector of the Google Chrome, and the response was this:

       

       

      <?xml version="1.0" ?>

       

       

      <partial-response>

        <changes>

          <update id="tr_j_idt7_Postscript">

            <![CDATA[

              <span id="tr_j_idt7_Postscript">

                <script type="text/javascript">var j_idt7_SF={};

              </script>

            </span>]]>

          </update>

          <update id="tr_j_idt7_Postscript">

            <![CDATA[

            <span id="tr_j_idt7_Postscript">

              <script type="text/javascript">var j_idt7_SF={};

              </script>

            </span>]]>

          </update>

          <update id="javax.faces.ViewState">

            <![CDATA[!zpmkrmv3f]]>

          </update>

          <eval>

            <![CDATA[TrPage.getInstance().__handlePprResponseAction('/PrjRadioDeMais/admin/teste.html');]]>

          </eval>

        </changes>

      </partial-response>

       

      The code than was generated this result:

       

      <?xml version="1.0" encoding="UTF-8"?>

      <!DOCTYPE html>

      <html xmlns="http://www.w3.org/1999/xhtml"

            xmlns:h="http://java.sun.com/jsf/html"

            xmlns:rich="http://richfaces.org/rich">

          <h:head>

              <title>Test Page</title>

          </h:head>

          <h:body>

              <h:form>

                  <rich:progressBar interval="2000"

                                    value="#{audioController.valueTmp}"

                                    maxValue="#{audioController.maximumTmp}"

                                    label="#{audioController.uploadLabel}"

                                    enabled="true"

                                    />

              </h:form>

          </h:body>

      </html>

      I do not know what to do

        • 1. Re: JSF2 + Richfaces 4 + Apache Trinidad 2 Error on Ajax Requests
          j0sh

          I've got the same problem:

           

          Error Rendering View[/login.xhtml] java.lang.NullPointerException at org.apache.myfaces.trinidadinternal.renderkit.core.ppr.PPRResponseWriter.<init>(PPRResponseWriter.java:62)

          ...

           

          and

           

          java.lang.NullPointerException

              at java.io.Writer.write(Writer.java:140)

              at com.sun.faces.context.AjaxExceptionHandlerImpl.handlePartialResponseError(Aj

          axExceptionHandlerImpl.java:200)

              at com.sun.faces.context.AjaxExceptionHandlerImpl.handle(AjaxExceptionHandlerIm

          pl.java:119)

              at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:119)

              at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)

              at javax.faces.webapp.FacesServlet.service(FacesServlet.java:313)

              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application

          FilterChain.java:304)

          ...

           

          Is there any configuration possibility to get Richfaces 4.1.0 work with Trinidad 2.0.0?