Hmm, Sessions are persisted so you cant destroy a session from a session events excepted the timeout which will do it automatically Le 25 nov. 2012 08:36, "Howard W. Smith, Jr." <smithh032...@gmail.com> a écrit :
> Interesting. So, when server shutdown, sessions are not destroyed? > > If the answer is yes, I guess you are telling me that I should invoke > session.invalidate() in a @PreDestroy of my CDI @SessionScoped UserBean? > > I have a sessionTimeout method on my UserBean already, it is usually called > by HttpSessionListener on sessionDestroyed. > > > On Sun, Nov 25, 2012 at 2:27 AM, Romain Manni-Bucau > <rmannibu...@gmail.com>wrote: > > > Because the session is not destroyed, you need to destroy it or wait the > > session timeout > > Le 25 nov. 2012 07:21, "Howard W. Smith, Jr." <smithh032...@gmail.com> a > > écrit : > > > > > I have the following defined for my HttpSessionListener, and I don't > see > > it > > > being executed (or showing up in server log) when I undeploy or > shutdown > > > TomEE. > > > > > > /* > > > * To change this template, choose Tools | Templates > > > * and open the template in the editor. > > > */ > > > package pf; > > > > > > import java.util.Date; > > > > > > import javax.inject.Inject; > > > > > > import javax.servlet.annotation.WebListener; > > > import javax.servlet.http.HttpSessionEvent; > > > import javax.servlet.http.HttpSessionListener; > > > > > > import jsf.users.pf_UsersController; > > > > > > /** > > > * > > > * @author Administrator > > > */ > > > @WebListener > > > public class UserHttpSessionListener implements HttpSessionListener { > > > > > > @Inject > > > private pf_UsersController userBean; > > > > > > @Override > > > public void sessionCreated(HttpSessionEvent event) { > > > // Do here the job. > > > } > > > > > > @Override > > > public void sessionDestroyed(HttpSessionEvent event) { > > > /* > > > * JSF Managed Beans > > > * > > > pf_UsersController userBean = (pf_UsersController) > > > event.getSession(). > > > > getAttribute("pf_usersController"); > > > */ > > > if (userBean != null && userBean.getUser() != null) { > > > String userName = userBean.getUser().getUserName(); > > > > > System.out.println("UserHttpSessionListener.sessionDestroyed(): > > > " + > > > userName + " session destroyed"); > > > userBean.sessionTimeout(); > > > } > > > } > > > > > > } > > > > > >