Struts Errors: Stream Closed

struts2.pngSince February, I have been working pretty extensively in the Struts 2 framework. This is my first interaction with a Java web framework in general and with Struts in particular.

Struts, like any other web framework, has some things it does extremely well and some things that it does not so well. One of the things that falls into the “not so well” category is Struts error handling. The framework does a horrible job of communicating to the developer what is going wrong in the application.

So, over the next few weeks, I intend to post some of the more difficult errors that I’ve found to troubleshoot. Today’s error is:

java.io.IOException: Stream closed
    at org.apache.jasper.runtime.JspWriterImpl.ensureOpen(JspWriterImpl.java:257)
    at org.apache.jasper.runtime.JspWriterImpl.flushBuffer(JspWriterImpl.java:161)
    at org.apache.jasper.runtime.JspWriterImpl.flush(JspWriterImpl.java:219) 

This error pops up during the execution of an action that is attempting to render a JSP as part of the result. The error is displayed in Tomcat directly in the browser even though the source compiles (and creates a valid JAR) with no errors. The problem to this little gem lies in the JSP itself and, often enough, in a collection.

For example, to reproduce this error, I modified a chunk of JSP for the application I’ve been working on to say this:

<s:select name="scheme" list="#{'Tel':'tel','SIP':'sip}" required="true"/>

You’ll notice that the list itself is missing a closing quote around the second value (‘sip should be ‘sip’).

Hope that helps!

Advertisements

About johnnywey

Welcome to A Regular Expression. This blog is designed to reflect my thoughts on life, music, software design, Apple, faith, philosophy, and whatever else I can think of.

Posted on June 2, 2008, in Java, Programming, Struts 2. Bookmark the permalink. 5 Comments.

  1. thanks for giving solution

  2. Thank you very much for the hint with the collections :-)

  3. Thanks so much

  4. hi johnnywey,
    we had a “stream closed” issue. Were trying for the past 2 weeks..!!!
    It’s like have a jsp file and other jsp files are included in it (jstl)

    You said about “missing a closing quote”. Is that the only reason for the “stream closed” exception. ?
    I am ready to share the code. Can you please look in to it ?

    • It’s been a few years since I’ve used Struts 2 and posted this, but I’d be happy to put a second set of eyes on it. My email is johnnywey at gmail. Basically, anything that is syntactically invalid may be causing your issue …

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: