You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Angelo Chen <an...@yahoo.com.hk> on 2009/02/19 13:47:19 UTC

T5:Cannot create a session after the response has been committed

Hi,

  I have following code used to logout a user:

 asm.set(MySession.class, null);
 global.getHTTPServletRequest().getSession().invalidate();
 cookies.removeCookieValue("my.login");
 
 but I'm getting this error with a Tomcat 5.25,but not all, any idea why?
 
 Thanks,
 
 Angelo
 
 
 
 [ERROR] [default] Servlet.service() for servlet default threw exception
java.lang.IllegalStateException: Cannot create a session after the response
has been committed
	at org.apache.catalina.connector.Request.doGetSession(Request.java:2221)
	...
	at
org.apache.tapestry5.internal.services.RequestImpl.getSession(RequestImpl.java:99)
	...
	at
org.apache.tapestry5.internal.services.SessionApplicationStatePersistenceStrategy.requestDidComplete(SessionApplicationStatePersistenceStrategy.java:126)
	at
org.apache.tapestry5.internal.services.EndOfRequestListenerHubImpl.fire(EndOfRequestListenerHubImpl.java:40)
	at
$EndOfRequestListenerHub_11f8e01679c.fire($EndOfRequestListenerHub_11f8e01679c.java)
	at
org.apache.tapestry5.services.TapestryModule$3.service(TapestryModule.java:625)
	at $RequestHandler_11f8e01679f.service($RequestHandler_11f8e01679f.java)
	at
org.apache.tapestry5.services.TapestryModule$2.service(TapestryModule.java:611)
	at $RequestHandler_11f8e01679f.service($RequestHandler_11f8e01679f.java)
	at
org.apache.tapestry5.internal.services.StaticFilesFilter.service(StaticFilesFilter.java:85)
	at $RequestHandler_11f8e01679f.service($RequestHandler_11f8e01679f.java)
	at org.abc.myapp.t5.services.AppModule$1.service(AppModule.java:217)
	at $RequestFilter_11f8e016798.service($RequestFilter_11f8e016798.java)
	at $RequestHandler_11f8e01679f.service($RequestHandler_11f8e01679f.java)
	at org.abc.myapp.t5.services.AppModule$2.service(AppModule.java:252)
	at $RequestFilter_11f8e016799.service($RequestFilter_11f8e016799.java)
	at $RequestHandler_11f8e01679f.service($RequestHandler_11f8e01679f.java)
	at
org.apache.tapestry5.internal.services.CheckForUpdatesFilter$2.invoke(CheckForUpdatesFilter.java:93)
	at
org.apache.tapestry5.internal.services.CheckForUpdatesFilter$2.invoke(CheckForUpdatesFilter.java:84)
	at
org.apache.tapestry5.ioc.internal.util.ConcurrentBarrier.withRead(ConcurrentBarrier.java:83)
	at
org.apache.tapestry5.internal.services.CheckForUpdatesFilter.service(CheckForUpdatesFilter.java:106)
	at $RequestHandler_11f8e01679f.service($RequestHandler_11f8e01679f.java)
	at $RequestHandler_11f8e016794.service($RequestHandler_11f8e016794.java)
	at
org.apache.tapestry5.services.TapestryModule$16.service(TapestryModule.java:1007)
	at
org.apache.tapestry5.upload.internal.services.MultipartServletRequestFilter.service(MultipartServletRequestFilter.java:44)
	at
$HttpServletRequestHandler_11f8e016795.service($HttpServletRequestHandler_11f8e016795.java)
	at
org.apache.tapestry5.internal.services.IgnoredPathsFilter.service(IgnoredPathsFilter.java:62)
	at
$HttpServletRequestFilter_11f8e016792.service($HttpServletRequestFilter_11f8e016792.java)
	at
$HttpServletRequestHandler_11f8e016795.service($HttpServletRequestHandler_11f8e016795.java)
	at
org.abc.myapp.t5.URLRewriteRequestFilter.service(URLRewriteRequestFilter.java:79)
	at
$HttpServletRequestHandler_11f8e016795.service($HttpServletRequestHandler_11f8e016795.java)
	at
$HttpServletRequestHandler_11f8e016791.service($HttpServletRequestHandler_11f8e016791.java)
	at org.apache.tapestry5.TapestryFilter.doFilter(TapestryFilter.java:179)
	at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
	at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
	at org.abc.myapp.Filter.doFilter(Filter.java:37)
	at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
	at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
	at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
	at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
	at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
	at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
	at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
	at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
	at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
	at
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
	at
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
	at
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
	at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
	at java.lang.Thread.run(Thread.java:619)
-- 
View this message in context: http://www.nabble.com/T5%3ACannot-create-a-session-after-the-response-has-been-committed-tp22099641p22099641.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T5:Cannot create a session after the response has been committed

Posted by Angelo Chen <an...@yahoo.com.hk>.
Hi Thiago,

Thanks for the reply, I have modified the code as you sugested, looks neat.
the problem seems having to do with @ApplicationState, I have this for the
same class in two places, also create it in a service, in one page, I have A
@ApplicationState  SessionDat _dat, in the same time I call the service
which might also create an instance of SessionDat, I'm still tracing...
thanks,

Angelo


Thiago H. de Paula Figueiredo wrote:
> 
> Please post the class that contains the snippet you posted here. By
> the way, you don't need to asm.set(MySession.class, null), as you're
> invalidating the session. You can also inject HttpServletRequest
> directly and instead of getting it from RequestGlobals. Better yet,
> inject Tapestry's Request and do:
> 
> Session session = request.getSession(false);
> if (session != null) {
> 	session.invalidate();
> }
> 
> -- 
> Thiago
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/T5%3ACannot-create-a-session-after-the-response-has-been-committed-tp22099641p22102555.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T5:Cannot create a session after the response has been committed

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Please post the class that contains the snippet you posted here. By
the way, you don't need to asm.set(MySession.class, null), as you're
invalidating the session. You can also inject HttpServletRequest
directly and instead of getting it from RequestGlobals. Better yet,
inject Tapestry's Request and do:

Session session = request.getSession(false);
if (session != null) {
	session.invalidate();
}

-- 
Thiago

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org