[jboss-user] [JBoss Seam] - AbstractResource subclass gets ClientAbortException writing

JakeC do-not-reply at jboss.com
Thu Nov 1 15:06:34 EDT 2007


While writing to the output stream, I get the following stacktrace:
11:03:00,031 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 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.java:88)
  |         at com.mycompany.myproject.Util.download(Util.java:93)

My code that does the writing is here:
	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");
  | 	            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);
  | 		}
  | 	}

It works just fine under http, but croaks in https. This is with a self-signed certificate, after accepting it, of course.

I checked the request path, and it is using the https protocol.

One problem I'm having on that page is that IE believes that the page contains both secure and unsecure items. However, our entire web app is completely under https, and there are no references to external resources. Looking at the source of the page, the only things with "http:" in them are the DOCTYPE dtd and the html xmlns declarations. Could that possibly have anything to do with it?

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4101048#4101048

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4101048



More information about the jboss-user mailing list