tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Greg Ward <>
Subject IllegalStateException from java.nio.charset.CharsetEncoder
Date Tue, 31 Aug 2004 15:04:26 GMT
On one of our servers, we're using Tomcat 4.1.29 under Java 1.4.2_02,
connecting to Apache 2.0.48 with mod_jk 1.2.4, all running on Red Hat
Linux 6.2.  (Wow, what a zoo of version numbers!)

Recently we got a support call because some (all?) HTTP requests were
failing with "Internal Server Error".  The support tech who took the
call noticed this in mod_jk's log file:

[Sat Aug 28 15:59:39 2004] [jk_ajp_common.c (1309)]: sending request to tomcat failed in send
loop. err=2
[Sat Aug 28 15:59:39 2004] [jk_ajp_common.c (1318)]: Error connecting to tomcat. Tomcat is
probably not started or is listening on the wrong port. Failed errno = 104 

(Errno 104, for the curious, is ECONNRESET -- "Connection reset by

He tried restarting Tomcat, which sounds like the right thing to me.
That didn't help, so then he tried restarting Apache.  Still nothing, so
he rebooted the server, after which things started working again.

Looking in catalina.out after the reboot, I saw this stack trace:

  java.lang.IllegalStateException: Current state = FLUSHED, new state = CODING_END
  at java.nio.charset.CharsetEncoder.throwIllegalStateException(
  at java.nio.charset.CharsetEncoder.encode(
  at sun.nio.cs.StreamEncoder$CharsetSE.flushLeftoverChar(
  at sun.nio.cs.StreamEncoder$CharsetSE.implClose(
  at sun.nio.cs.StreamEncoder.close(
  at org.apache.catalina.connector.ResponseBase.finishResponse(
  at org.apache.catalina.connector.HttpResponseBase.finishResponse(
  at org.apache.ajp.tomcat4.Ajp13Response.finishResponse(
  at org.apache.ajp.tomcat4.Ajp13Processor.process(

Of course, catalina.out is clobbered with every Tomcat restart, so
there's no way of knowing if this exception is actually the cause of the
problem, i.e. if it was happening before the first Tomcat restart.
Nevertheless, I poked around a bit and stumbled across these two entries
in Tomcat's bug database:

Both of these have a *nearly* identical stack trace (the connector is
different -- org.apache.catalina.connector.http.HttpProcessor vs
org.apache.ajp.tomcat4.Ajp13Processor in my example) that ends with the
same IllegalStateException.  Both are about 2 years old, around the time
that Tomcat 4.0 and Java 1.4 were in beta.  And it sorta-kinda-vaguely
sounded like the bug(s), whatever they were, have been fixed.

First of all, from those two bug reports, it's not clear if this is a
Tomcat bug or a Java bug.  Second of all, has anyone else seen this on
stable, mature versions of Tomcat 4.0 and Java 1.4 (ie. 4.0.29 and

Thanks --


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message