java.util.zip.DataFormatException:数据检查不正确

时间:2015-04-06 10:35:09

标签: jsf firefox richfaces servlet-filters

我在加载JSF页面时遇到了下面提到的错误。页面成功加载,页面上的所需操作也已完成,但出现此错误。

JSF页面包含选项卡面板,如果我尝试将可用项目中的一些项目包含到包含的项目中,则会出现错误。以下是列表的XHTML。

<a4j:outputPanel id="selectItems">
    <div id="div_selectItems" class="scroll_container">
        <s:div styleClass="dialogueAttribute">
            <rich:listShuttle sourceValue="#{itemReportEditor.itemsList}"
                              targetValue="#{itemReportEntry.itemReportData}"
                              var="items"
                              listsHeight="28em"
                              sourceListWidth="45em"
                              targetListWidth="45em"
                              sourceCaptionLabel="Available Items"
                              targetCaptionLabel="Included Items"
                              removeAllControlLabel="Remove all"
                              removeControlLabel="Remove"
                              copyControlLabel="Add"
                              copyAllControlLabel="Add all"
                              fastOrderControlsVisible="true"
                              orderControlsVisible="true"
                              converter="#{itemReportEditor.itemReportDataModelConverter}">
                <rich:column>
                    <f:facet name="header">
                        <h:outputText title="Performance item name"
                                      value="Name"/>
                    </f:facet>
                    <h:outputText value="#{items['itemName']}"></h:outputText>
                </rich:column>

                <rich:column>
                    <f:facet name="header">
                        <h:outputText title="Performance Item Protocol"
                                      value="Protocol"/>
                    </f:facet>
                    <h:outputText value="#{items['protocol']}"></h:outputText>
                </rich:column>

                <a4j:support event="onlistchanged"
                             action="#{itemReportEntry.updateItemsList()}"
                             reRender="la"
                             oncomplete="resizeScrollBox2();"
                             status="workingStatus"
                             eventsQueue="ajaxQueue"/>
            </rich:listShuttle>
        </s:div>
    </div>
</a4j:outputPanel>

我正在尝试使用列表快递从左侧到右侧添加一些项目,我在日志中遇到以下异常(仅在FireFox浏览器中,未在Google Chrome中观察到此问题)(能够全部应用)正确的变化,只是得到以下异常)。我的FireFox版本是35.0.1

2015-04-06 15:42:34,272 ERROR [http-0.0.0.0-8080-8] org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/client].[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:369)
    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:488)
    at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
    at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
    at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)
    at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
    at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
    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.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
    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:598)
    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)
    ... 30 more

谷歌搜索我发现&#34;问题似乎是像'&#39;!&#39;由FireFox转换为&#39;%21&#39;。以下过滤器会将%21转换回&#39;!&#39;所以可以在服务器中找到资源&#34;

在我的情况下,我只是在日志中获取异常,但所有源都已成功加载

为了消除异常,我添加了过滤器

package juno.sa.server;

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
    }
}
<filter>
    <filter-name>RichFacesFirefox11Filter</filter-name>
    <filter-class>juno.sa.server.RichFacesFirefox11Filter</filter-class>
</filter>
<filter-mapping>
    <filter-name>RichFacesFirefox11Filter</filter-name>
    <url-pattern>*.seam</url-pattern>
</filter-mapping>

1 个答案:

答案 0 :(得分:0)

即使我收到这样的例外。 引起:java.util.zip.ZipException:数据检查不正确     at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:147)

但在我的情况下,根本原因是我尝试读取的流是使用flate编码器压缩的,因此尝试解压缩的流是InflaterInputStream。

在我的情况下发生的事情是,最后一个字节中存在的数据不是eof参数,而是实际数据,eof参数存在于最后一个字节之前的某个流中。因此,当流输出块数据的最后一个字节时,它无法找到eof,因此会引发错误的数据检查。

也许在你的最后验证它......在你的结尾也可能是同样的问题。