iframe导致ClientAbortException:org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:369)上的java.io.IOException [英] iframe causes ClientAbortException: java.io.IOException at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:369)

查看:1443
本文介绍了iframe导致ClientAbortException:org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:369)上的java.io.IOException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用iframe来显示pdf文件,并且可以让用户保存,打印等.但是,当用户向后导航或在其他地方导航时,总是会抛出此错误提示:

I'm using the iframe for showing a pdf file, with the posibility for the user to save it, print it, etc. But when the user navigates back or elsewhere this error ist always thrown:

ClientAbortException:  java.io.IOException
    at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:369)
    at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:448)
    at org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:363)
    at org.apache.catalina.connector.OutputBuffer.writeBytes(OutputBuffer.java:392)
    at org.apache.catalina.connector.OutputBuffer.write(OutputBuffer.java:381)
    at org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputStream.java:89)
    at java.nio.channels.Channels$WritableByteChannelImpl.write(Channels.java:296)
    at com.sun.faces.application.resource.ResourceHandlerImpl.handleResourceRequest(ResourceHandlerImpl.java:277)
    at javax.faces.application.ResourceHandlerWrapper.handleResourceRequest(ResourceHandlerWrapper.java:119)
    at org.primefaces.application.PrimeResourceHandler.handleResourceRequest(PrimeResourceHandler.java:91)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:310)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
    at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:877)
    at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:594)
    at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1675)
    at java.lang.Thread.run(Thread.java:662)

我该怎么办?

推荐答案

ClientAbortException

通常,您可以忽略它.当客户端仍在页面加载时突然中止HTTP请求时,将引发此异常.当客户端按下 Esc ,或匆匆离开或关闭浏览器,或者网络中断,甚至着火时,就会发生这种情况.所有这些完全是您无法控制的.

Generally, you can just ignore it. This exception will be thrown when the client has abruptly aborted the HTTP request while the page is still loading. This will occur when the client pressed Esc, or hastily navigated away, or closed the browser, or got network outage, or even caught fire. All of this is totally out your control.

stacktrace表示这是由<h:outputStylesheet><h:outputScript><h:graphicImage>(以及PrimeFaces等效项)处理的JSF资源请求.因此,这是在浏览器尝试下载CSS,JS和/或图像资源时发生的.

The stacktrace indicates that it's a JSF resource request as handled by <h:outputStylesheet>, <h:outputScript> and <h:graphicImage> (and the PrimeFaces equivalents). So this was happening while the browser is trying to download a CSS, JS and/or image resource.

好吧,您只是要与之共存".如果您担心服务器日志中的噪音",则可以考虑创建一个 servlet过滤器,以消除那些例外.

Well, you've just to "live with it". If you bother about the "noise" in the server logs, you could consider to create a servlet filter which suppresses those exceptions.

try {
    chain.doFilter(request, response);
} catch (ClientAbortException e) {
    // Log a single line instead of whole stacktrace, or just ignore it.
}

请注意,这是一个特定于servlet容器的异常类(来自Catalina/Tomcat),因此这种过滤器与特定的servlet容器制造商紧密耦合(即,不可移植到Glassfish或其他产品中).由于它是IOException的子类,因此您可能想捕获它并进行Class#getSimpleName()检查.

Please note that this is a servletcontainer-specific exception class (from Catalina/Tomcat) and thus such a filter is this way tight coupled to the specific servletcontainer make (i.e. it's not portable to Glassfish or others). As it's a subclass of IOException, you might want to catch it instead and do a Class#getSimpleName() check.

这篇关于iframe导致ClientAbortException:org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:369)上的java.io.IOException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆