简体   繁体   中英

iframe causes ClientAbortException: java.io.IOException at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:369)

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)

What can I do?

ClientAbortException

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.

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.

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.
}

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 (ie 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM