{"id":667,"date":"2005-03-30T23:15:37","date_gmt":"2005-03-31T03:15:37","guid":{"rendered":"http:\/\/wordpress.cephas.net\/?p=667"},"modified":"2005-03-30T23:15:37","modified_gmt":"2005-03-31T03:15:37","slug":"tomcat-50x-and-clientabortexception","status":"publish","type":"post","link":"https:\/\/cephas.net\/blog\/2005\/03\/30\/tomcat-50x-and-clientabortexception\/","title":{"rendered":"Tomcat 5.0.x and ClientAbortException"},"content":{"rendered":"<p>I&#8217;ve got an application deployed on Tomcat 5.0.28 that, when in production, uses log4j with the <a href=\"http:\/\/logging.apache.org\/log4j\/docs\/api\/org\/apache\/log4j\/net\/SMTPAppender.html\">SMTP appender<\/a> to send relevant debug \/ error messages via email.  Soon after deploying the application I began receiving messages from the application which contained this stack trace:<br \/>\n<code><br \/>\njava.io.IOException: ClientAbortException:  java.net.SocketException: Connection reset by peer: socket write error at org.apache.coyote.tomcat5.OutputBuffer.doFlush(OutputBuffer.java:331) at org.apache.coyote.tomcat5.OutputBuffer.flush(OutputBuffer.java:297) at org.apache.coyote.tomcat5.CoyoteOutputStream.flush(CoyoteOutputStream.java:85) at sun.nio.cs.StreamEncoder$CharsetSE.implFlush(Unknown Source) at sun.nio.cs.StreamEncoder.flush(Unknown Source) at java.io.OutputStreamWriter.flush(Unknown Source)\tat java.io.BufferedWriter.flush(Unknown Source)....<br \/>\n<\/code><br \/>\nThe stack trace isn&#8217;t anything special: you&#8217;ll get a <a href=\"http:\/\/jakarta.apache.org\/tomcat\/tomcat-5.0-doc\/catalina\/docs\/api\/org\/apache\/catalina\/connector\/ClientAbortException.html\">ClientAbortException<\/a> whenever the HTTP client on the other end closes the connection prematurely (ie: before Tomcat has a chance to complete the flush of information to the output stream).  The problem is that it pollutes your log file, or in my case, my inbox because I was receiving an email every time one of these errors occurred.  My log4j configuration file looked something like this:<br \/>\n<code><br \/>\nlog4j.rootCategory=ERROR, SMTPAPPENDER<br \/>\nlog4j.appender.SMTPAPPENDER.To=me@mydomain.com<br \/>\nlog4j.appender.SMTPAPPENDER.layout=org.apache.log4j.PatternLayout<br \/>\nlog4j.appender.SMTPAPPENDER=org.apache.log4j.net.SMTPAppender<br \/>\nlog4j.appender.SMTPAPPENDER.Subject=[my app] ERROR<br \/>\nlog4j.appender.SMTPAPPENDER.BufferSize=512<br \/>\nlog4j.appender.SMTPAPPENDER.From=errors@mydomain.com<br \/>\nlog4j.appender.SMTPAPPENDER.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n<br \/>\nlog4j.appender.SMTPAPPENDER.SMTPHost=localhost<br \/>\n<\/code><br \/>\nwhich, in log4j parlance, means that I want any messages that are of type ERROR or FATAL sent to me via email.  Instead I should have started it off with this:<br \/>\n<code><br \/>\nlog4j.rootCategory=FATAL, SMTPAPPENDER<br \/>\nlog4j.category.com.mycompany=ERROR, SMTPAPPENDER<br \/>\n...<br \/>\n<\/code><br \/>\nwhich translated means that I want any FATAL errors in any package sent to me via the SMTPAPPENDER but any messages of type ERROR or FATAL in the package com.mycompany sent to me as well.  This effectively cuts out the unnecessary sending of ClientAbortException messages, while still generating the messages that I want to receive.<\/p>\n<p>(Note: if your problem isn&#8217;t with log4j, but instead with your Tomcat log files, check out the debug settings in <a href=\"http:\/\/jakarta.apache.org\/tomcat\/tomcat-5.0-doc\/config\/server.html\">Server<\/a>, <a href=\"http:\/\/jakarta.apache.org\/tomcat\/tomcat-5.0-doc\/config\/service.html\">Service<\/a>, <a href=\"http:\/\/jakarta.apache.org\/tomcat\/tomcat-5.0-doc\/config\/engine.html\">Engine<\/a> and <a href=\"http:\/\/jakarta.apache.org\/tomcat\/tomcat-5.0-doc\/config\/host.html\">Host<\/a> elements of your Tomcat conf\\server.xml.)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve got an application deployed on Tomcat 5.0.28 that, when in production, uses log4j with the SMTP appender to send relevant debug \/ error messages via email. Soon after deploying the application I began receiving messages from the application which contained this stack trace: java.io.IOException: ClientAbortException: java.net.SocketException: Connection reset by peer: socket write error at &hellip; <a href=\"https:\/\/cephas.net\/blog\/2005\/03\/30\/tomcat-50x-and-clientabortexception\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Tomcat 5.0.x and ClientAbortException<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[3,12],"tags":[],"_links":{"self":[{"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/posts\/667"}],"collection":[{"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/comments?post=667"}],"version-history":[{"count":0,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/posts\/667\/revisions"}],"wp:attachment":[{"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/media?parent=667"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/categories?post=667"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/tags?post=667"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}