4 Replies Latest reply on Dec 20, 2012 2:18 PM by nstoddar2

    "Session already invalidated" exception

    nstoddar2

      I'm trying to find the cause of an exception that gets logged in our application.  There was a flurry of these exceptions over the course of two days.

       

      {code}

      2012-11-22 08:30:12,170 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/deleted].[Faces Servlet]] ( http-deleted%2F10.68.4.206-8080-87) Servlet.service() for servlet Faces Servlet threw exception

      java.lang.IllegalStateException: getAttribute: Session already invalidated

              at org.apache.catalina.session.StandardSession.getAttribute(StandardSession.java:1032)

              at org.apache.catalina.session.StandardSessionFacade.getAttribute(StandardSessionFacade.java:110)

              at org.jboss.seam.mock.MockExternalContext$3.getAttribute(MockExternalContext.java:369)

              at org.jboss.seam.mock.MockExternalContext$AttributeMap.get(MockExternalContext.java:393)

              at org.jboss.seam.contexts.ServerConversationContext.get(ServerConversationContext.java:103)

              at org.jboss.seam.contexts.Contexts.lookupInStatefulContexts(Contexts.java:189)

              at org.jboss.seam.Component.getInstance(Component.java:1949)

              at org.jboss.seam.Component.getInstance(Component.java:1944)

              at org.jboss.seam.Component.getInstanceInAllNamespaces(Component.java:2311)

              at org.jboss.seam.Component.getValueToInject(Component.java:2263)

              at org.jboss.seam.Component.injectAttributes(Component.java:1703)

              at org.jboss.seam.Component.inject(Component.java:1521)

              at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:61)

              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)

              at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)

              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)

              at org.jboss.seam.core.SynchronizationInterceptor.aroundInvoke(SynchronizationInterceptor.java:32)

              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)

              at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)

              at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:185)

              at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:103)

              at [deleted for security]

              at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:50)

              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)

              at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)

              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:235)

              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)

              at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)

              at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)

              at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)

              at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)

              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:158)

              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)

              at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)

              at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)

              at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)

              at java.lang.Thread.run(Thread.java:662)

      {code}

       

      The part that's confusing for me is that LoggingFilter, line 50 is inside a check for a non-null session (line 44), so it must have existed before proceeding.  We're running version 2.1.1.GA right now.  Is anybody aware of any reason that we would be seeing these exceptions in our logs?

        • 1. Re: "Session already invalidated" exception
          mkouba

          Hi,

          org.jboss.seam.web.LoggingFilter does not create a new HTTP session (see servletRequest.getSession(false)) and in fact it doesn't do anything if there is no active HTTP session available, just causes the next filter in the chain to be invoked.

           

          Looking at the provided stack trace fragment I see two clues:

          1. The exception is thrown when Seam tries to perform bijection on a component - this indicates the HTTP session was probably invalidated manually (javax.servlet.http.HttpSession.invalidate()) which is not a good idea in Seam apps (use org.jboss.seam.web.Session.invalidate() instead)

          2. The stack contains MockExternalContext which is used when handling uncaught exception in ExceptionFilter to mock JSF context (see also org.jboss.seam.mock.MockFacesContext)

          • 2. Re: "Session already invalidated" exception
            nstoddar2

            Martin,

             

            Any idea why I don't see ExceptionFilter in the stacktrace?

            • 3. Re: "Session already invalidated" exception
              mkouba

              Sorry, have no idea. I suppose it's not hidden in the [deleted for security] area? I'd try to enable debug logging for internal Seam components and identify the use case when the exception occurs.

              • 4. Re: "Session already invalidated" exception
                nstoddar2

                Thanks for all the help, Martin.