Uploaded image for project: 'Tapestry 5'
  1. Tapestry 5
  2. TAP5-413

Invalidating the session may cause an exception at the end of the request if there is a "dirty" ASO

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.0.18
    • Fix Version/s: 5.1.0.0
    • Component/s: tapestry-core
    • Labels:
      None

      Description

      Since 5.0.18, Tapestry blows up (IllegalStateException) on return from an event handler that invalidates the session AND uses an ASO. I believe this is an unintended consequence of TAP-399.

      The workaround is to nullify the ASO, but it's not at all obvious from the exception.

      Here's an example. It blows up unless we either:
      (a) comment out the first line of onActionFromLogOut() because it references _myASO; or
      (b) un-comment the line that sets _myASO to null.

      <html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
      <body>
      <a t:type="actionlink" t:id="LogOut" href="#">Log Out</a>
      </body>
      </html>

      package jumpstart.web.pages;

      import org.apache.tapestry5.annotations.ApplicationState;
      import org.apache.tapestry5.ioc.annotations.Inject;
      import org.apache.tapestry5.services.RequestGlobals;
      import org.apache.tapestry5.services.Session;

      public class TestInvalidate {

      @Inject
      private RequestGlobals _requestGlobals;

      @ApplicationState
      private String _myASO;

      void setupRender()

      { _myASO = "Everything's fine"; }

      void onActionFromLogOut() {
      System.out.println("_myASO = " + _myASO + ".");

      Session session = _requestGlobals.getRequest().getSession(false);
      if (session != null)

      { // _myASO = null; session.invalidate(); }

      }
      }

      11:55:21,811 INFO [STDOUT] _myASO = Everything's fine.
      11:55:21,812 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:2301)
      at org.apache.catalina.connector.Request.getSession(Request.java:2075)
      at org.apache.catalina.connector.RequestFacade.getSession(RequestFacade.java:833)
      at org.apache.tapestry5.internal.services.RequestImpl.getSession(RequestImpl.java:99)
      at $Request_11e2dd6dd65.getSession($Request_11e2dd6dd65.java)
      at $Request_11e2dd6dd2d.getSession($Request_11e2dd6dd2d.java)
      at org.apache.tapestry5.internal.services.SessionApplicationStatePersistenceStrategy.requestDidComplete(SessionApplicationStatePersistenceStrategy.java:126)
      at org.apache.tapestry5.internal.services.EndOfRequestListenerHubImpl.fire(EndOfRequestListenerHubImpl.java:40)
      at $EndOfRequestListenerHub_11e2dd6dd44.fire($EndOfRequestListenerHub_11e2dd6dd44.java)
      at org.apache.tapestry5.services.TapestryModule$3.service(TapestryModule.java:625)
      at $RequestHandler_11e2dd6dd47.service($RequestHandler_11e2dd6dd47.java)
      at org.apache.tapestry5.services.TapestryModule$2.service(TapestryModule.java:611)
      at $RequestHandler_11e2dd6dd47.service($RequestHandler_11e2dd6dd47.java)
      at org.apache.tapestry5.internal.services.StaticFilesFilter.service(StaticFilesFilter.java:85)
      at $RequestHandler_11e2dd6dd47.service($RequestHandler_11e2dd6dd47.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_11e2dd6dd47.service($RequestHandler_11e2dd6dd47.java)
      at $RequestHandler_11e2dd6dd3e.service($RequestHandler_11e2dd6dd3e.java)
      at org.apache.tapestry5.services.TapestryModule$16.service(TapestryModule.java:1007)
      at org.apache.tapestry5.internal.services.IgnoredPathsFilter.service(IgnoredPathsFilter.java:62)
      at $HttpServletRequestFilter_11e2dd6dd3d.service($HttpServletRequestFilter_11e2dd6dd3d.java)
      at $HttpServletRequestHandler_11e2dd6dd3f.service($HttpServletRequestHandler_11e2dd6dd3f.java)
      at $HttpServletRequestHandler_11e2dd6dd3c.service($HttpServletRequestHandler_11e2dd6dd3c.java)
      at org.apache.tapestry5.TapestryFilter.doFilter(TapestryFilter.java:179)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
      at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
      at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
      at java.lang.Thread.run(Thread.java:613)

        Attachments

          Activity

            People

            • Assignee:
              hlship Howard M. Lewis Ship
              Reporter:
              geoffcallender Geoff Callender
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: