IllegalStateException: Current state = FLUSHED, new state = CODING

Discussion in 'Java' started by Stewart, May 29, 2007.

  1. Stewart

    Stewart Guest

    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)
     
    Stewart, May 29, 2007
    #1
    1. Advertising

  2. Stewart

    rajeshmuthu

    Joined:
    Apr 14, 2009
    Messages:
    3
    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)
     
    rajeshmuthu, Apr 14, 2009
    #2
    1. Advertising

  3. Stewart

    rajeshmuthu

    Joined:
    Apr 14, 2009
    Messages:
    3
    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);
    }

    }
     
    rajeshmuthu, Apr 16, 2009
    #3
  4. Stewart

    alexg

    Joined:
    May 13, 2009
    Messages:
    1
    Hi rajeshmuthu,
    I am having the same issue.
    Can you confirm that this solution worked?
     
    alexg, May 13, 2009
    #4
  5. Stewart

    rajeshmuthu

    Joined:
    Apr 14, 2009
    Messages:
    3
    Its working without any problem.
     
    rajeshmuthu, May 13, 2009
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?TWFkcyBCcnlkZWdhYXJk?=

    web.config custom config handler is not flushed

    =?Utf-8?B?TWFkcyBCcnlkZWdhYXJk?=, Dec 20, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    470
    =?Utf-8?B?TWFkcyBCcnlkZWdhYXJk?=
    Dec 20, 2004
  2. Replies:
    3
    Views:
    17,126
    zz78_gang
    Aug 17, 2007
  3. John Pote

    knowing when file is flushed to disk

    John Pote, Aug 9, 2006, in forum: Python
    Replies:
    5
    Views:
    370
    Dennis Lee Bieber
    Aug 10, 2006
  4. Thomas Guettler

    stdout not flushed before os.execvp()

    Thomas Guettler, Oct 17, 2006, in forum: Python
    Replies:
    3
    Views:
    463
    Fulvio
    Oct 18, 2006
  5. MindClass

    Data not flushed at the moment

    MindClass, Nov 22, 2006, in forum: Python
    Replies:
    1
    Views:
    270
    MindClass
    Nov 22, 2006
Loading...

Share This Page