You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Gurkan Erdogdu (JIRA)" <de...@myfaces.apache.org> on 2011/02/09 09:53:57 UTC

[jira] Created: (MYFACES-3040) @PreDestroy Has Called 2 times

@PreDestroy Has Called 2 times
------------------------------

                 Key: MYFACES-3040
                 URL: https://issues.apache.org/jira/browse/MYFACES-3040
             Project: MyFaces Core
          Issue Type: Bug
          Components: JSR-314
    Affects Versions: 2.0.3
            Reporter: Gurkan Erdogdu


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

 - When StartupServletcontextListener # sessionDestroyed
 - When StartupServletcontextListener # attributeRemoved


-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (MYFACES-3040) @PreDestroy Has Called 2 times

Posted by "Mark Struberg (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/MYFACES-3040?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12992393#comment-12992393 ] 

Mark Struberg commented on MYFACES-3040:
----------------------------------------

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

> @PreDestroy Has Called 2 times
> ------------------------------
>
>                 Key: MYFACES-3040
>                 URL: https://issues.apache.org/jira/browse/MYFACES-3040
>             Project: MyFaces Core
>          Issue Type: Bug
>          Components: JSR-314
>    Affects Versions: 2.0.3
>            Reporter: Gurkan Erdogdu
>
> When session is invalidated, session scoped bean @PreDestroy method has called two times
>  - When StartupServletcontextListener # sessionDestroyed
>  - When StartupServletcontextListener # attributeRemoved

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Resolved: (MYFACES-3040) @PreDestroy Has Called 2 times

Posted by "Leonardo Uribe (JIRA)" <de...@myfaces.apache.org>.
     [ https://issues.apache.org/jira/browse/MYFACES-3040?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Leonardo Uribe resolved MYFACES-3040.
-------------------------------------

       Resolution: Fixed
    Fix Version/s: 2.0.5-SNAPSHOT
         Assignee: Leonardo Uribe

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.


> @PreDestroy Has Called 2 times
> ------------------------------
>
>                 Key: MYFACES-3040
>                 URL: https://issues.apache.org/jira/browse/MYFACES-3040
>             Project: MyFaces Core
>          Issue Type: Bug
>          Components: JSR-314
>    Affects Versions: 2.0.3
>            Reporter: Gurkan Erdogdu
>            Assignee: Leonardo Uribe
>             Fix For: 2.0.5-SNAPSHOT
>
>
> When session is invalidated, session scoped bean @PreDestroy method has called two times
>  - When StartupServletcontextListener # sessionDestroyed
>  - When StartupServletcontextListener # attributeRemoved

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (MYFACES-3040) @PreDestroy Has Called 2 times

Posted by "Gurkan Erdogdu (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/MYFACES-3040?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12992452#comment-12992452 ] 

Gurkan Erdogdu commented on MYFACES-3040:
-----------------------------------------

Yes.

> @PreDestroy Has Called 2 times
> ------------------------------
>
>                 Key: MYFACES-3040
>                 URL: https://issues.apache.org/jira/browse/MYFACES-3040
>             Project: MyFaces Core
>          Issue Type: Bug
>          Components: JSR-314
>    Affects Versions: 2.0.3
>            Reporter: Gurkan Erdogdu
>
> When session is invalidated, session scoped bean @PreDestroy method has called two times
>  - When StartupServletcontextListener # sessionDestroyed
>  - When StartupServletcontextListener # attributeRemoved

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira