tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tom van Wietmarschen <...@service2media.com>
Subject Response already comitted on first line of servlet
Date Thu, 03 Jul 2008 08:20:12 GMT
L.S,

I'm investigating a problem in which one of our servlets doesn't return 
any headers most of the time (sometimes it does work, but it seems quite 
random) After a bit of digging I found out that the reason the headers 
aren't added is that the response already seems to be comitted.

I've added the following two lines to the top of my Servlet (these are 
the first 2 lines of doGet())

        if(response.isCommitted())
            logger.error("WTF?");

and it seems that the response is already commited on the 1st line of my 
servlet, before I've done anything to it. Also, I've got no filters 
defined for this servlet. I've set a breakpoint on the logger.error line 
and this is the stacktrace at that point:

Daemon Thread [TP-Processor3] (Suspended (breakpoint at line 31 in 
ImageLoader))   
    ImageLoader.doGet(HttpServletRequest, HttpServletResponse) line: 31   
    ImageLoader(HttpServlet).service(HttpServletRequest, 
HttpServletResponse) line: 690   
    ImageLoader(HttpServlet).service(ServletRequest, ServletResponse) 
line: 803   
    ApplicationFilterChain.internalDoFilter(ServletRequest, 
ServletResponse) line: 269   
    ApplicationFilterChain.doFilter(ServletRequest, ServletResponse) 
line: 188   
    StandardWrapperValve.invoke(Request, Response) line: 213   
    StandardContextValve.invoke(Request, Response) line: 174   
    StandardHostValve.invoke(Request, Response) line: 127   
    ErrorReportValve.invoke(Request, Response) line: 117   
    StandardEngineValve.invoke(Request, Response) line: 108   
    CoyoteAdapter.service(Request, Response) line: 174   
    JkCoyoteHandler.invoke(Msg, MsgContext) line: 200   
    HandlerRequest.invoke(Msg, MsgContext) line: 283   
    ChannelSocket.invoke(Msg, MsgContext) line: 773   
    ChannelSocket.processConnection(MsgContext) line: 703   
    ChannelSocket$SocketConnection.runIt(Object[]) line: 895   
    ThreadPool$ControlRunnable.run() line: 689   
    ThreadWithAttributes(Thread).run() line: 595   

Looking at the enclosed CoyoteResponse object shows that the 'committed' 
variable is set to true, but bytesWritten is 0, contentLength is 0, 
contentType is null, etc. so there doesn't seem to have been anything 
done to the response that could have triggered a commit.

I've also tried adding a response.reset() at the top of the method, this 
also fails, 10 lines down the road the response is committed again (I 
haven't touched the response object yet at that point in the code, I'm 
also doing nothing multithreaded to the response object myself. 
Furthermore for debugging I'm only using 1 client and that client is 
firing requests serially and not in parallel). Requests are going 
through a mod_jk on an Apache2.2 server, but direct connections to the 
tomcat seem to show the same behaviour.

A response.reset() just before the response.addHeader seems to work, but 
this, of course, isn't a real solution.

Does anyone have a clue what's going on ? I can't find anything in our 
code that could trigger this behaviour, could it be a bug in Tomcat or 
am I missing something ?

Sincerely,
    Tom
-- 

**Tom van Wietmarschen**
Software Engineer

Service2Media B.V.
Vreelandseweg 7
1216 CG Hilversum

Capitool 41           
7521 PL Enschede

Tel  +31 (0)35 626 46 12
Fax +31 (0)35 626 46 13
www.service2media.com <http://www.service2media.com>


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message