IllegalStateException: Current state = FLUSHED, new state = CODING

S

Stewart

This mysterious exception is being thrown at random intervals by my
Tomcat installtion. Once its thrown once, it will always rethrow with
each request until Tomcat is bounced.

I have searched all over google for any clues about this. Most
references to it are referring to outdated versions of Tomcat, Java,
log4j etc. In fact, references to this error later than 2003 seem rare
indeed; yet here it is.

I'm completely lost because:
(1) it's the only exception being thrown - there are no other errors
or behaviour of interest, except that no response gets to the client
(2) the stack trace contains no reference to any of my own code. It
involves only Tomcat, log4j and Sun's nio.

Anyone have any clues?

Tomcat version is 5.5.16.
Java version is 1.5.0_08.
Log4j version is 1.2.13.


May 29, 2007 3:50:40 PM org.apache.catalina.connector.CoyoteAdapter
service
SEVERE: An exception or error occurred in the container during the
request processing
java.lang.IllegalStateException: Current state = FLUSHED, new state =
CODING
at
java.nio.charset.CharsetEncoder.throwIllegalStateException(Unknown
Source)
at java.nio.charset.CharsetEncoder.encode(Unknown Source)
at sun.nio.cs.StreamEncoder$CharsetSE.implWrite(Unknown
Source)
at sun.nio.cs.StreamEncoder.write(Unknown Source)
at sun.nio.cs.StreamEncoder.write(Unknown Source)
at java.io_OutputStreamWriter.write(Unknown Source)
at java.io.Writer.write(Unknown Source)
at org.apache.log4j.helpers.QuietWriter.write(QuietWriter.java:
47)
at
org.apache.log4j.WriterAppender.subAppend(WriterAppender.java:301)
at
org.apache.log4j.DailyRollingFileAppender.subAppend(DailyRollingFileAppender.java:
358)
at org.apache.log4j.WriterAppender.append(WriterAppender.java:
159)
at
org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:230)
at
org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:
65)
at org.apache.log4j.Category.callAppenders(Category.java:203)
at org.apache.log4j.Category.forcedLog(Category.java:388)
at org.apache.log4j.Category.log(Category.java:853)
at
org.apache.commons.logging.impl.Log4JLogger.error(Log4JLogger.java:
193)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:
260)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:
178)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:
126)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:
105)
at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:
541)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:
107)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:
148)
at
org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:199)
at
org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:282)
at
org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:754)
at
org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:
684)
at org.apache.jk.common.ChannelSocket
$SocketConnection.runIt(ChannelSocket.java:876)
at org.apache.tomcat.util.threads.ThreadPool
$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Unknown Source)
 
Joined
Apr 14, 2009
Messages
3
Reaction score
0
Same problem

Hi
Do you find a solution? I'm having the same issue.
I'm using JBoss.
JBoss Version: jboss-4.0.2
Java version: jdk1.5.0_06
velocity version: 1.6.1
log4j: 1.2.14

Thanks
RM

java.lang.IllegalStateException: Current state = FLUSHED, new state = CODING
java.lang.IllegalStateException: Current state = FLUSHED, new state = CODING
at java.nio.charset.CharsetEncoder.throwIllegalStateException(CharsetEncoder.java:941)
at java.nio.charset.CharsetEncoder.encode(CharsetEncoder.java:537)
at sun.nio.cs.StreamEncoder$CharsetSE.implWrite(StreamEncoder.java:384)
at sun.nio.cs.StreamEncoder.write(StreamEncoder.java:136)
at sun.nio.cs.StreamEncoder.write(StreamEncoder.java:146)
at java.io_OutputStreamWriter.write(OutputStreamWriter.java:204)
at java.io.Writer.write(Writer.java:126)
at org.apache.log4j.helpers.CountingQuietWriter.write(CountingQuietWriter.java:44)
at org.apache.log4j.WriterAppender.subAppend(WriterAppender.java:301)
at org.apache.log4j.RollingFileAppender.subAppend(RollingFileAppender.java:236)
at org.apache.log4j.WriterAppender.append(WriterAppender.java:159)
at org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:230)
at org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:65)
at org.apache.log4j.Category.callAppenders(Category.java:203)
at org.apache.log4j.Category.forcedLog(Category.java:388)
at org.apache.log4j.Category.error(Category.java:302)
at org.apache.velocity.runtime.log.SimpleLog4JLogSystem.logVelocityMessage(SimpleLog4JLogSystem.java:151)
at org.apache.velocity.runtime.log.LogChuteSystem.log(LogChuteSystem.java:74)
at org.apache.velocity.runtime.log.Log.log(Log.java:86)
at org.apache.velocity.runtime.log.Log.error(Log.java:226)
at org.apache.velocity.runtime.resource.ResourceManagerImpl.getResource(ResourceManagerImpl.java:374)
at org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:1400)
at org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:1380)
at org.apache.velocity.app.VelocityEngine.getTemplate(VelocityEngine.java:401)
 
Joined
Apr 14, 2009
Messages
3
Reaction score
0
Solution Found

I found a solution. I don't know its a permanent one or not. Since this solution is implemented yesterday without any problems.
When Initializing velocity servlet this line was missing previously in our code.
"velocity.setProperty("runtime.log.logsystem.log4j.category", "velocity");" Which I think caused the problem. Once added, its running without any issues.
Sample code:

public void init(ServletConfig config) throws ServletException {
super.init();
String dir = System.getProperty("com.abc", "C:/abc");
abcPropertiesFile = dir + "/properties/abc.properties";
abcProperties = PropertiesHandler.getProperties(abcPropertiesFile);
templateDir = abcProperties.getProperty("rssDir");
velocity = new VelocityEngine();
velocity.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS,"org.apache.velocity.runtime.log.SimpleLog4JLogSystem");
velocity.setProperty("runtime.log.logsystem.log4j.category", "velocity");
velocity.setProperty("file.resource.loader.path", templateDir);
velocity.setProperty("velocimacro.permissions.allow.inline.to.replace.global","true");
velocity.setProperty("velocimacro.library", "macros." + "rss" + ",sys/macros." + "rss");
try {
velocity.init();
}
catch (Exception e1) {
logger.info(e1, e1);
}

}
 
Joined
May 13, 2009
Messages
1
Reaction score
0
Hi rajeshmuthu,
I am having the same issue.
Can you confirm that this solution worked?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top