tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Martin Gainty" <mgai...@hotmail.com>
Subject Re: ClientAbortException writing file to servlet's output stream over SSL in IE
Date Sat, 03 Nov 2007 01:39:02 GMT
Please display /conf/catalina.policy SocketPermission for your
SocketConnection e.g.
// grant codeBase "file:${catalina.home}/webapps/examples/-" {
//      permission java.net.SocketPermission "*.noaa.gov:80", "connect";
// };

M--
----- Original Message -----
From: "Jake C" <buddhabuddy@hotmail.com>
To: <users@tomcat.apache.org>
Sent: Friday, November 02, 2007 7:36 PM
Subject: ClientAbortException writing file to servlet's output stream over
SSL in IE



This is in JBOSS 4.0.5-GA. I would guess that it is using Tomcat 5.5 from
the log line "[TomcatDeployer] deploy, ctxPath=/,
warUrl=.../deploy/jbossweb-tomcat55.sar/ROOT.war/"

This downloads a binary file. I know that the client is not closing the
browser.

It works just fine over HTTP.

It works just fine in HTTPS in FireFox.

It throws the following exception in IE:

11:41:42,202 INFO  [Util] 0: Writing 16,384 bytes of 57,567 to buffer
11:41:42,202 INFO  [Util] 0: Writing 16,384 bytes of 57,567 to buffer
11:41:42,202 INFO  [Util] 0: Writing 16,384 bytes of 57,567 to buffer
11:41:42,202 ERROR [Util] Error serving file: <path to file>
ClientAbortException:  java.net.SocketException: Connection reset by peer:
socket write error
        at
org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:
366)
        at
org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:433)
        at org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:348)
        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.ja
va:88)
        at com.mycompany.myproject.Util.download(Util.java:93)
        at
com.mycompany.myproject.DocumentResource.getResource(DocumentResource.java:1
22)
        at
org.jboss.seam.servlet.ResourceServlet.doGet(ResourceServlet.java:68)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:252)
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:173)
        at org.jboss.seam.web.ContextFilter.doFilter(ContextFilter.java:56)
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:202)
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:173)
        at
org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:63)
        at
org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:57)
        at
org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
        at
org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:60)
        at
org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
        at
org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
        at
org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
        at
org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:79)
        at
org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
        at org.jboss.seam.web.SeamFilter.doFilter(SeamFilter.java:84)
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:202)
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:173)
        at
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.ja
va:96)
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:202)
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:173)
        at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
va:213)
        at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
va:178)
        at
org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssoci
ationValve.java:175)
        at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase
java:432)
        at
org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:
74)
        at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126
)
        at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105
)
        at
org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionVa
lve.java:156)
        at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
:107)
        at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
        at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
        at
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processC
onnection(Http11BaseProtocol.java:664)
        at
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.jav
a:527)
        at
org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThre
ad.java:112)
        at java.lang.Thread.run(Thread.java:619)
Caused by: java.net.SocketException: Software caused connection abort:
socket write error
        at java.net.SocketOutputStream.socketWrite0(Native Method)
        at
java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
        at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
        at
com.sun.net.ssl.internal.ssl.OutputRecord.writeBuffer(OutputRecord.java:283)
        at
com.sun.net.ssl.internal.ssl.OutputRecord.write(OutputRecord.java:272)
        at
com.sun.net.ssl.internal.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:66
5)
        at
com.sun.net.ssl.internal.ssl.AppOutputStream.write(AppOutputStream.java:59)
        at
org.apache.coyote.http11.InternalOutputBuffer.realWriteBytes(InternalOutputB
uffer.java:746)
        at
org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:433)
        at org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:348)
        at
org.apache.coyote.http11.InternalOutputBuffer$OutputStreamOutputBuffer.doWri
te(InternalOutputBuffer.java:769)
        at
org.apache.coyote.http11.filters.ChunkedOutputFilter.doWrite(ChunkedOutputFi
lter.java:125)
        at
org.apache.coyote.http11.InternalOutputBuffer.doWrite(InternalOutputBuffer.j
ava:579)
        at org.apache.coyote.Response.doWrite(Response.java:559)
        at
org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:
361)
        ... 46 more

Here is my servlet code:

    public static void download(HttpServletResponse response, File file,
String downloadName)
            throws IOException {
        FileInputStream fis = null;
        OutputStream os = null;
        if(file != null && file.exists()) {
            try {
                byte[] buf = new byte[BUF_SIZE];
                if(downloadName != null && downloadName.trim().length() > 0)
                    response.setHeader("Content-Disposition",
"attachment;filename=\"" +
                            downloadName + "\"");
                response.setHeader("Cache-Control", "no-store");
                response.setHeader("Pragma", "no-cache");
                response.setDateHeader("Expires", 0);
                response.setContentType("application/octet-stream");
                response.setContentLength((int)file.length());

                fis = new FileInputStream(file);
                os = response.getOutputStream();
                int len = -1;
                int x = 0;
                while((len = fis.read(buf)) != -1) {
                    log.info("{0}: Writing {1} bytes of {2} to buffer", x,
len, file.length());
                    os.write(buf, 0, len);
                }
            } catch (Throwable t) {
                log.error("Error serving file: "+file, t);
                response.sendError(HttpServletResponse.SC_NOT_FOUND);
            } finally {
                if(fis != null) try{fis.close();}catch(Throwable t){
                    log.warn("Error closing input stream: " +
t.getMessage(), t);
                }
                if( os != null) try{ os.flush();}catch(Throwable t){

if("org.apache.catalina.connector.ClientAbortException".equals(t.getClass().
getCanonicalName()))
                        log.info("client canceled download");
                    else
                        log.warn("Error flushing output stream: " +
t.getClass().getCanonicalName(), t);
                }
                if( os != null) try{ os.close();}catch(Throwable t){
                    log.warn("Error closing output stream: " +
t.getMessage(), t);
                }
            }
        } else {
            log.error("Error serving unknown file: "+file);
            response.sendError(HttpServletResponse.SC_NOT_FOUND);
        }
    }

To get SSL running, I uncommented the SSL Connector tag in server.xml and
changed the port to 443. I also changed the port to 80 and the rediredtPort
to 443 in the HTTP Conector tag. I am using a self-signed certificate
generated with JDK 1.5 keytool app.

It works even in IE if the file is small.

Any ideas what I'm doing wrong?

Am I asking in the correct place? :-)

_________________________________________________________________
Windows Live Hotmail and Microsoft Office Outlook – together at last. Get it
now.
http://office.microsoft.com/en-us/outlook/HA102225181033.aspx?pid=CL10062697
1033


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message