Bug 44646 - IllegalStateException when using CometConnectionManagerValve
Summary: IllegalStateException when using CometConnectionManagerValve
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 6
Classification: Unclassified
Component: Connectors (show other bugs)
Version: 6.0.16
Hardware: PC Windows XP
: P2 normal (vote)
Target Milestone: default
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-03-20 09:33 UTC by Dan Rabe
Modified: 2008-04-05 11:38 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dan Rabe 2008-03-20 09:33:14 UTC
We're writing an application that processes requests using both a normal servlet and a CometProcessor. The normal servlet handles user authentication and logout (among other things). Once the user has been authenticated, the client makes a Comet request, which is open until the server has something to push to the client. When the user decides to log out, we need to stop processing Comet events for that client. I enabled the CometConnectionManagerValve in context.xml, hoping I would get an END event when the session goes away. Instead, I get an IllegalStateException:
Mar 10, 2008 2:05:41 PM org.apache.catalina.connector.CoyoteAdapter event
SEVERE: An exception or error occurred in the container during the request processing
java.lang.IllegalStateException: Cannot create a session after the response has been committed
   at org.apache.catalina.connector.Request.doGetSession(Request.java:2301)
   at org.apache.catalina.connector.Request.getSession(Request.java:2075)
   at org.apache.catalina.valves.CometConnectionManagerValve.event(CometConnectionManagerValve.java:311)
   at org.apache.catalina.core.StandardHostValve.event(StandardHostValve.java:179)
   at org.apache.catalina.valves.ValveBase.event(ValveBase.java:200)
   at org.apache.catalina.core.StandardEngineValve.event(StandardEngineValve.java:128)
   at org.apache.catalina.connector.CoyoteAdapter.event(CoyoteAdapter.java:198)
   at org.apache.coyote.http11.Http11NioProcessor.event(Http11NioProcessor.java:749)
   at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.event(Http11NioProtocol.java:653)
   at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:2080)
   at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
   at java.lang.Thread.run(Thread.java:619)

Presumably my servlet handles the "logout" request, and after sending a response to the client, calls invalidate() on the HttpSession. Subsequently, CometConnectionManagerValue.event() calls request.getSession(true), resulting in the IllegalStateException.
Comment 1 Mark Thomas 2008-03-23 16:26:07 UTC
The problem was wider than just the issue reported here. It should now all be fixed in trunk. The patch is http://svn.apache.org/viewvc?rev=640273&view=rev

I have proposed the patch for 6.0.x.
Comment 2 Mark Thomas 2008-04-05 11:37:50 UTC
This has been fixed in svn and will be includedin 6.0.17 onwards.