You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Leonardo Uribe (JIRA)" <de...@myfaces.apache.org> on 2011/02/22 00:46:38 UTC

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

     [ 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