Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.3
    • Fix Version/s: 2.0.5
    • Component/s: JSR-314
    • Labels:
      None

      Description

      When session is invalidated, session scoped bean @PreDestroy method has called two times

      • When StartupServletcontextListener # sessionDestroyed
      • When StartupServletcontextListener # attributeRemoved

        Activity

        Hide
        Mark Struberg added a comment -

        Do you mean JSF managed beans with scope @javax.faces.bean.SessionScoped? (and no CDI in place)

        Show
        Mark Struberg added a comment - Do you mean JSF managed beans with scope @javax.faces.bean.SessionScoped? (and no CDI in place)
        Hide
        Gurkan Erdogdu added a comment -

        Yes.

        Show
        Gurkan Erdogdu added a comment - Yes.
        Hide
        Leonardo Uribe added a comment -

        I tried it and it is true. The solution is comment the code on servletDestroyed.

        It is know JSF 2.0 spec section 5.4.1 says this:

        "...Methods on managed beans declared to be in request, session, or application scope, annotated with @PreDestroy, must be called by the JSF implementation before the bean is removed from its scope or before the scope itself is destroyed, whichever comes first...."

        Unfortunately, it is not possible to handle it on servletDestroyed first and then on attributeRemoved, because there is no way to know when the session object is being destroyed from the listener, so the best bet is let the code in just one place.

        Show
        Leonardo Uribe added a comment - I tried it and it is true. The solution is comment the code on servletDestroyed. It is know JSF 2.0 spec section 5.4.1 says this: "...Methods on managed beans declared to be in request, session, or application scope, annotated with @PreDestroy, must be called by the JSF implementation before the bean is removed from its scope or before the scope itself is destroyed, whichever comes first...." Unfortunately, it is not possible to handle it on servletDestroyed first and then on attributeRemoved, because there is no way to know when the session object is being destroyed from the listener, so the best bet is let the code in just one place.

          People

          • Assignee:
            Leonardo Uribe
            Reporter:
            Gurkan Erdogdu
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development