javax.faces.FacesException: Error decode resource data while loading JSF page

AngelsandDemons picture AngelsandDemons · Apr 16, 2012 · Viewed 11.3k times · Source

I am getting the below mentioned error while loading the JSF page. The page gets loaded successfully and the desired operation on the page is also done but this error comes.

The jsf page contains tab panels and on click of each tab panel the error comes. Also I found that if I keep a certain portion of my page as rendered=false then the error does not come but the portion is again not rerendered.

I am using JSF2.0 with JSPs. and RF3.3

ERROR [[Faces Servlet]] Servlet.service() for servlet Faces Servlet threw exception
javax.faces.FacesException: Error decode resource data
at org.ajax4jsf.resource.ResourceBuilderImpl.decrypt(ResourceBuilderImpl.java:627)
at org.ajax4jsf.resource.ResourceBuilderImpl.getResourceDataForKey(ResourceBuilderImpl.java:371)
at org.ajax4jsf.resource.InternetResourceService.serviceResource(InternetResourceService.java:156)
at org.ajax4jsf.resource.InternetResourceService.serviceResource(InternetResourceService.java:141)
at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:508)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
at org.apache.catalina.core.StandardContextValve.__invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:601)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.util.zip.DataFormatException: incorrect data check
at java.util.zip.Inflater.inflateBytes(Native Method)
at java.util.zip.Inflater.inflate(Inflater.java:238)
at java.util.zip.Inflater.inflate(Inflater.java:256)
at org.ajax4jsf.resource.ResourceBuilderImpl.decrypt(ResourceBuilderImpl.java:621)
    ... 25 more

Code snippet of jsf page and component which when rendered=false in bean does not throws the above mentioned error.

<rich:tab ignoreDupResponses="true" id="tabModify"
    style="overflow:auto" styleClass="richTab" label="#{}"
    eventsQueue="queueForTab" actionListener="#{}">
    <rich:layout>
        <rich:layoutPanel position="right" id="pnlmodfy">
            <h:form id="frmModify">
                <h:panelGrid>
                    <h:outputLabel value="#{} * :" escape="false" styleClass="intro" />
                    <h:outputText value=" : " styleClass="intro" />
                    <rich:comboBox id="Mdfy" value="#{Bean.str}"
                        suggestionValues="#{Bean.arraylist}">
                        <a4j:support id="id"
                            actionListener="#{Bean.actionListener}"
                            ajaxSingle="true" event="onchange" reRender="modify">
                        </a4j:support>
                    </rich:comboBox>
                </h:panelGrid>
                <a4j:outputPanel id="modify" ajaxRendered="true">
                    <h:panelGrid columns="3" id="modify">
                        <h:outputText value="Description *" styleClass="intro"/>
                        <h:outputText value=" : " styleClass="intro" />
                        <h:inputTextarea id="Desc" required="true"
                            styleClass="textBox" label="Description"
                            value="#{Bean.strDesc}">
                        </h:inputTextarea>

If outputPanel is bind to backing bean for rendering and intially the value is set to false the error does not come. However on rerendering the outputPanel, the outputPanel never appears.

The problem basically is appearing on including component. I have 4 tabs in the page. On two tabs I am using the listshuttle(2 components on each tab). On both the tabs the arraylist of source and target binded to listshuttle are same.

Is it due to this that I am binding the same list to both the shuttles.However the same code in another tab works absolutely fine....

ListShuttle code:-

<h:outputText value="Select" styleClass="intro" rendered="#{!empty Bean.lstAvailable}"/>
<h:outputText value=" : " styleClass="intro" />
<rich:listShuttle id="listShuttleN" sourceValue="#{Bean.lstAvailable}" targetValue="#{KPIManagement.lstSelected}"  var="items" listsHeight="100" sourceListWidth="100" targetListWidth="100" sourceCaptionLabel="Available" targetCaptionLabel="Selected" rendered="#{!empty Bean.lstAvailable}">       
<rich:column>
<h:outputLabel value="#{items}"></h:outputLabel>
</rich:column>
</rich:listShuttle>

ArrayList code:-

ArrayList<String> lstAvailable=new ArrayList<String>();

Inside some function

lstAvailable=class.function(Some variable))
this.setLstAvailable(lstAvailable);

The possible answer for this post as observed is that I am facing some kind of browser issues..

When same application is accessed from another machine there is absolutely no exception... This is strange as I am using Firefox 11.0 and another machine has Firefox 4.0

Can this really be an issue with the browser.??

Answer

AngelsandDemons picture AngelsandDemons · Jun 21, 2012

The issue is now occuring very prominently on all Firefox upgrades>10.0.. There is some change in the Firefox browser script which does not allow the tree to be read properly.

Please add the following in your project to eliminate all Firefox browser related problems:-

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;

public class RichFacesFirefox11Filter implements Filter {

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        chain.doFilter(new HttpServletRequestWrapper((HttpServletRequest) request) {
            @Override
            public String getRequestURI() {
                try {
                    return URLDecoder.decode(super.getRequestURI(), "UTF-8");
                } catch (UnsupportedEncodingException e) {

                    throw new IllegalStateException("Cannot decode request URI.", e);
                }
            }
        }, response);
    }

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        // do nothing
    }

    @Override
    public void destroy() {
        // do nothing
    }

}

And please make the entry of this filter in your web.xml file also.

<filter>
    <filter-name>RichFacesFirefox11Filter</filter-name>
    <filter-class>Packagename.RichFacesFirefox11Filter</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>RichFacesFirefox11Filter</filter-name>
    <url-pattern>/a4j/*</url-pattern>
  </filter-mapping>

This will surely eliminate all your problems related to Firefox Browsers and RichFaces components.