tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hunter Hillegas <hhille...@jacobstern.com>
Subject RE: Bug in Tomcat? Response already committed?
Date Fri, 11 Aug 2000 17:30:10 GMT
Perhaps this is a bug in tomcat3.1?

I just checked out 3.2 beta 2 and it works fine without code changes...


Hunter Hillegas, MCP
Web Engineer / System Administrator - Jacob Stern & Sons, Inc.
hhillegas@jacobstern.com
805-565-1411 PH * 805-565-8684 FAX

 -----Original Message-----
From: 	kert@core.tb.cz [mailto:kert@core.tb.cz] 
Sent:	Friday, August 11, 2000 9:11 AM
To:	'tomcat-user@jakarta.apache.org'
Subject:	RE: Bug in Tomcat? Response already committed?

hello & see below my 1%:

On Fri, 11 Aug 2000, Hunter Hillegas wrote:

> My code doesn't change the headers at this point...
> 
> I didn't have an error page specified until I started troubleshooting.
> 
> I tried adding an error page directive at the top of the page and the
error
> page doesn't come up (I assume because some content has already been sent
to
> the browser)...
> 
> I created another simple test page... Here is the code:
> 
>
----------------------------------------------------------------------------
> -------------
> 
> <%@ page errorPage="error.jsp"%>
> 
> <%
> HttpSession theSession = request.getSession(false);
> %>

I'd recommend to use <%@ page session="false" %> if you don't want the
session to be created by default. HttpSession instance is then called
simply 'session'.

> 
> <%
> shoppingCart cart = (shoppingCart)theSession.getValue("shoppingCart");

So are you sure that there's no NullPointerException at the line
above? Note that the 'session' (or 'theSession') CAN be null, because it
was created using request.getSession(false) ...
I recommend checking all logs, because quite often "Response has already
been commited" is just (bad) 'sort of wrapper' for some other exception
(ClassNotFound, ClassCast etc...)


> 
> cartItem cartItem = cart.getItem(0);

This is not an error, but seems a little dangerous to me ... giving the
same name to both class and one of its instances...

That's all; hope this helps a little ...

Roman Kratochvil


> %>
> 
> Family: <%= cartItem.getPartFamily() %>
> 
> 
> And this generates the same error:
> 
> Error: 500
> Location: /e_commerce/test.jsp
> Internal Servlet Error:
> java.lang.IllegalStateException: Response has already been committed
> 	at
>
org.apache.tomcat.core.HttpServletResponseFacade.sendError(HttpServletRespon
> seFacade.java:157)
> 	at
> org.apache.jasper.runtime.JspServlet.unknownException(JspServlet.java:299)
> 	at org.apache.jasper.runtime.JspServlet.service(JspServlet.java:377)
> 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> 	at
>
org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:503)
> 	at
> org.apache.tomcat.core.ContextManager.service(ContextManager.java:559)
> 	at
>
org.apache.tomcat.service.connector.Ajp12ConnectionHandler.processConnection
> (Ajp12ConnectionHandler.java:156)
> 	at
>
org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEndpoint.java:338
> )
> 	at java.lang.Thread.run(Thread.java:484)
> 
> but still isn't bringing up the error page I specified...
> 
> Any help is appreciated as I can't really get any work done at this point.
> Thanks!!!
> 
> 
> Hunter Hillegas, MCP
> Web Engineer / System Administrator - Jacob Stern & Sons, Inc.
> hhillegas@jacobstern.com
> 805-565-1411 PH * 805-565-8684 FAX
> 
>  -----Original Message-----
> From: 	Amos Shapira [mailto:amos.shapira@webcollage.com] 
> Sent:	Friday, August 11, 2000 3:43 AM
> To:	'tomcat-user@jakarta.apache.org'
> Subject:	RE: Bug in Tomcat? Response already committed?
> 
> In general, this error indicates that you tried to change the headers
after
> some data was already sent to the client (the first buffer became
> full and had to be flushed down the TCP connection to make room for
> the rest of the response).
> 
> "Changing headers" should include things like change of status code
> (a redirect is such a thing), changing/adding a cookie, chaning the
caching
> status of the page etc.
> 
> Since, as far as I remember, the error handling is a special case of
> redirecting
> (to the error page), this could be the explenation (i.e. your page caused
an
> error after some data was already sent).
> 
> Possible conslusion - try to concentrate all the possible error-generating
> code at the top before anything is sent to the user.
> 
> You can also try enlarging the buffer, but this isn't scalable.
> 
> I also think I saw an interface to get notified when a buffer is about to
be
> flushed (and thus "commit" the response), which might allow you to deffer
> to commitment of the response, but I haven't tried it.
> 
> --Amos Shapira
> WebCollage
> 
> > -----Original Message-----
> > From: ALEXANDROS KOTSIRAS [mailto:ALEXANDROS_K@prodigy.net]
> > Sent: Friday, August 11, 2000 8:22 AM
> > To: tomcat-user@jakarta.apache.org
> > Subject: Re: Bug in Tomcat? Response already committed?
> > 
> > 
> > I had a hard time with this error several times.
> > Have a look at the mailing list archives there should be plenty of
> > responses.
> > 
> > If i remember well it has to do with lack of 
> > errorPage="error.jsp" attribute
> > in the <% page declaration.
> > Try to add an error page.
> > There is an error in either your bean or the .jsp page but 
> > the message is
> > missleading...
> > 
> > In any case it has nothing to do with obtaining an 
> > outputstream before you
> > forward as it looks like in the beginning..
> > 
> > ----- Original Message -----
> > From: Hunter Hillegas <hhillegas@jacobstern.com>
> > To: <tomcat-user@jakarta.apache.org>
> > Sent: Thursday, August 10, 2000 6:03 PM
> > Subject: Bug in Tomcat? Response already committed?
> > 
> > 
> > > I tried to search the bug database for Jakarta stuff - but 
> > it's down...
> > >
> > > Any way, I'm trying to figure out if I found a bug or what...
> > >
> > > I'm using Tomcat 3.1 (release) on JDK1.3 (beta) on Linux 
> > 2.2 (Debian).
> > >
> > > I have a JSP page that creates instances of a class called 
> > shoppingCart.
> > >
> > > The shoppingCart class contains a vector that stores 
> > objects of another
> > > class called cartItem.
> > >
> > > There is a method in shoppingCart that returns cartItem by 
> > vector index
> > > number. The problem comes when I call this method:
> > >
> > > I get this error:
> > >
> > > Error: 500
> > > Location: /e_commerce/index.jsp
> > > Internal Servlet Error:
> > > java.lang.IllegalStateException: Response has already been committed
> > > at
> > >
> > org.apache.tomcat.core.HttpServletResponseFacade.sendError(Htt
> pServletRespon
> > > seFacade.java:157)
> > > at
> > > 
> > org.apache.jasper.runtime.JspServlet.unknownException(JspServl
> et.java:299)
> > > at org.apache.jasper.runtime.JspServlet.service(JspServlet.java:377)
> > > at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> > > at
> > >
> > org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWra
> pper.java:503)
> > > at
> > > 
> > org.apache.tomcat.core.ContextManager.service(ContextManager.java:559)
> > > at
> > >
> > org.apache.tomcat.service.connector.Ajp12ConnectionHandler.pro
> > cessConnection
> > > (Ajp12ConnectionHandler.java:156)
> > > at
> > >
> > org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEnd
> > point.java:338
> > > )
> > > at java.lang.Thread.run(Thread.java:484)
> > >
> > >
> > > I tried substituting the return with a pre-defined cartItem 
> > instead of
> > > looking it up in the vector to make sure it wasn't failing 
> > on the vector
> > > lookup... The HTML in the page before the method call comes 
> > to the browser
> > > just fine but the rest of the HTML, including a JSP include 
> > of a footer
> > > page, doesn't come across.
> > >
> > > I've had very little success with the tomcat-users mailing list so I
> > thought
> > > I'd ask some of the developers. Any help is appreciated!
> > >
> > >
> > > Hunter Hillegas, MCP
> > > Web Engineer / System Administrator - Jacob Stern & Sons, Inc.
> > > hhillegas@jacobstern.com
> > > 805-565-1411 PH * 805-565-8684 FAX
> > >
> > >
> > 
> 

Mime
View raw message