Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

mysterious "java.io.IOException: Stream not marked"

813 views
Skip to first unread message

Seth Gordon

unread,
Jul 18, 2001, 3:06:00 PM7/18/01
to
I have a class with a "next()" method that looks something like this:

public VirtualBand next() throws IndexOutOfBoundsException,
IOException {
// source is a BufferedReader
if (source.markSupported()) {
System.out.println("~~~ yes, this reader allows marks");
} else {
System.out.println("~~~ uh-oh");
}
System.out.println("~~~ exited the if-else");
System.out.flush();
// lots of code, with occasional calls to
// source.mark(foo) and source.reset() --
// a System.out.println and System.out.flush()
// precede each of those calls
}

This class is instantiated, and the method called, within a servlet,
using this code:

public Page resultPage() throws Exception {

String consDir = req.getParameter("consdir");
// snip
try {
File consFile = new File(consDir, "cons");
// snip
BufferedReader consFileReader =
new BufferedReader(new FileReader(consFile));
Snipper thisSnipper = new Snipper(enzyme, consFileReader);
TreeSet sortedVirtualFragments = new TreeSet();
while (thisSnipper.hasNext()) {
VirtualBand thisBand = (VirtualBand) thisSnipper.next();
// snip
sortedVirtualFragments.add(thisBand);
}
// and more snip, setting the "page" variable
} catch (Exception e) {
formatException(e);
}
return page;
}

However, when I try to read the page that the servlet generates, I get a
java.io.IOException "Stream not marked". Before the exception is
thrown, the "yes, this reader allows marks" message appears on standard
output, but none of the other messages -- not even "exited the if-else"
-- appear.

Here's the stack trace:

java.io.IOException: Stream not marked
at java.lang.Throwable.fillInStackTrace(Native Method)
at java.lang.Throwable.fillInStackTrace(Compiled Code)
at java.lang.Throwable.(Compiled Code)
at java.lang.Exception.(Compiled Code)
at java.io.IOException.(Compiled Code)
at java.io.BufferedReader.reset(Compiled Code)
at fin.Snipper.next(Compiled Code)
at fin.FinsgtFormModule.resultPage(Compiled Code)
at fin.FinsgtFormModule.branch(Compiled Code)
at edu.mit.wi.squid.web.FormModule.doGet(Compiled Code)
at edu.mit.wi.squid.web.SQServlet.doGet(Compiled Code)
at javax.servlet.http.HttpServlet.service(Compiled Code)
at javax.servlet.http.HttpServlet.service(Compiled Code)
at com.livesoftware.jrun.JRun.runServlet(Compiled Code)
at com.livesoftware.jrun.JRunGeneric.handleConnection(Compiled
Code)
at
com.livesoftware.jrun.JRunGeneric.handleProxyConnection(Compiled Code)
at
com.livesoftware.jrun.service.proxy.JRunProxyServiceHandler.handleRequest(Compiled
Code)
at
com.livesoftware.jrun.service.ThreadConfigHandler.run(Compiled Code)

The use of "fin.Snipper.next(Compiled Code)" instead of an explicit line
number doesn't help matters, either....

What's going on?

adTHANKSvance for your help,
--
Where is the information? Obscured by the data.
Where is the data? Somewhere in the %$#@* database!
// seth gordon // wi/mit ctr for genome research //
// se...@genome.wi.mit.edu // standard disclaimer //

JavaJosh

unread,
Jul 18, 2001, 5:54:01 PM7/18/01
to
Simplify and retest. Try the code outside of the Servlet container.

No way is anyone going to debug for you here.

"Seth Gordon" <se...@genome.wi.mit.edu> wrote in message
news:3B55DE18...@genome.wi.mit.edu...

Steve Horsley

unread,
Jul 19, 2001, 4:36:34 AM7/19/01
to
Seth Gordon <se...@genome.wi.mit.edu> wrote in message news:<3B55DE18...@genome.wi.mit.edu>...
> I have a class with a "next()" method that looks something like this:
>
> // lots of code, with occasional calls to
> // source.mark(foo) and source.reset() --
>
> Here's the stack trace:
>
> java.io.IOException: Stream not marked
> at java.lang.Throwable.fillInStackTrace(Native Method)
> at java.lang.Throwable.fillInStackTrace(Compiled Code)
> at java.lang.Throwable.(Compiled Code)
> at java.lang.Exception.(Compiled Code)
> at java.io.IOException.(Compiled Code)
> at java.io.BufferedReader.reset(Compiled Code)
> at fin.Snipper.next(Compiled Code)
> at fin.FinsgtFormModule.resultPage(Compiled Code)
> at fin.FinsgtFormModule.branch(Compiled Code)
> at edu.mit.wi.squid.web.FormModule.doGet(Compiled Code)
> at edu.mit.wi.squid.web.SQServlet.doGet(Compiled Code)
> at javax.servlet.http.HttpServlet.service(Compiled Code)
> at javax.servlet.http.HttpServlet.service(Compiled Code)
> at com.livesoftware.jrun.JRun.runServlet(Compiled Code)

Looks to me like you are calling source.reset before you ever
called source.mark. It might be easiest just to call source.mark
before you enter your "// lots of code", to make sure the stream
is always marked.

Steve.

Seth Gordon

unread,
Jul 23, 2001, 12:04:01 PM7/23/01
to
JavaJosh wrote:
>
> Simplify and retest. Try the code outside of the Servlet container.
>
> No way is anyone going to debug for you here.

Thanks. I did that, and nailed down the place where the code was
resetting without marking.

The System.out.println() statement before the error appeared in the
non-servlet version, even though it didn't appear in the servlet
version. I don't know why there was that inconsistency, but solving
that mystery isn't one of my priorities today...

0 new messages