Jetty
  1. Jetty
  2. JETTY-910

Session not available in ServletRequestListeners

    Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 7.0.0pre4, 6.1.15.rc3
    • Fix Version/s: 6.1.15.rc4, 7.0.2, 7.1.0
    • Component/s: Servlet
    • Labels:
      None
    • Number of attachments :
      0

      Description


      The context listeners are called before session handler

        Activity

        Hide
        Greg Wilkins added a comment -

        from struberg@apache.org

        Show
        Greg Wilkins added a comment - from struberg@apache.org
        Hide
        Mark Struberg added a comment -

        thanks Greg!

        The corresponding issue in the apache Jira with a stack trace:

        Show
        Mark Struberg added a comment - thanks Greg! The corresponding issue in the apache Jira with a stack trace:
        Show
        Mark Struberg added a comment - https://issues.apache.org/jira/browse/OWB-78
        Hide
        Mark Struberg added a comment -

        howto reproduce:

        $> svn co http://svn.apache.org/repos/asf/incubator/openwebbeans/trunk openwebbeans
        $> cd openwebbeans
        $> mvn clean install
        $> cd samples/guess
        $> mvn -Pjetty clean package jetty:run
        then browse http://localhost:8080/guess

        the code involved:

        public class WebBeansConfigurationListener implements ServletContextListener, ServletRequestListener, HttpSessionListener {
        public void requestInitialized(ServletRequestEvent event)

        { this.lifeCycle.requestStarted(event); }

        ...

        public final class WebBeansLifeCycle {
        public void requestStarted(ServletRequestEvent event)

        { ContextFactory.initRequestContext((HttpServletRequest) event.getServletRequest()); }

        ...

        public final class ContextFactory {
        public static void initRequestContext(HttpServletRequest request)
        {
        requestContext.set(new RequestContext());// set thread local
        requestContext.get().setActive(true);

        if (request != null)

        { HttpSession session = request.getSession(); <-- kawumm initSessionContext(session); initApplicationContext(request.getSession().getServletContext()); }

        }
        ...

        txs in advance,
        strub

        Show
        Mark Struberg added a comment - howto reproduce: $> svn co http://svn.apache.org/repos/asf/incubator/openwebbeans/trunk openwebbeans $> cd openwebbeans $> mvn clean install $> cd samples/guess $> mvn -Pjetty clean package jetty:run then browse http://localhost:8080/guess the code involved: public class WebBeansConfigurationListener implements ServletContextListener, ServletRequestListener, HttpSessionListener { public void requestInitialized(ServletRequestEvent event) { this.lifeCycle.requestStarted(event); } ... public final class WebBeansLifeCycle { public void requestStarted(ServletRequestEvent event) { ContextFactory.initRequestContext((HttpServletRequest) event.getServletRequest()); } ... public final class ContextFactory { public static void initRequestContext(HttpServletRequest request) { requestContext.set(new RequestContext());// set thread local requestContext.get().setActive(true); if (request != null) { HttpSession session = request.getSession(); <-- kawumm initSessionContext(session); initApplicationContext(request.getSession().getServletContext()); } } ... txs in advance, strub
        Hide
        Greg Wilkins added a comment -

        A fix for jetty-6 has been committed.
        I need to make a better test harness and port the jetty-7

        Show
        Greg Wilkins added a comment - A fix for jetty-6 has been committed. I need to make a better test harness and port the jetty-7
        Hide
        Mark Struberg added a comment -

        Greg, thanks for fixing this so quickly!

        I can confirm that the OpenWebBeans guess sample works now with Revision 4603 of the jetty-6.1 branch.

        Show
        Mark Struberg added a comment - Greg, thanks for fixing this so quickly! I can confirm that the OpenWebBeans guess sample works now with Revision 4603 of the jetty-6.1 branch.
        Hide
        Greg Wilkins added a comment -

        Still broken for 7.0.1

        Show
        Greg Wilkins added a comment - Still broken for 7.0.1
        Hide
        Greg Wilkins added a comment -

        Using the scoped handler in jetty-7 to apply the session manager before the listeners are invoked.

        Show
        Greg Wilkins added a comment - Using the scoped handler in jetty-7 to apply the session manager before the listeners are invoked.

          People

          • Assignee:
            Greg Wilkins
            Reporter:
            Greg Wilkins
          • Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: