Note that there are some explanatory texts on larger screens.

plurals
  1. POCleanup JSF session scope bean when application shutdown
    text
    copied!<p>I need to invalidate and cleanup active session objects when the JSF application shutdown or tomact shutdown. The following is the code I have written in application scoped bean</p> <pre><code>@PreDestroy public void shutdown(){ Map appMap = FacesContext.getCurrentInstance().getExternalContext().getApplicationMap(); Map&lt;String,HttpSession&gt; userSessionMap=(Map&lt;String,HttpSession&gt;)appMap.get("USERS"); log.info("userSessionMap " + userSessionMap); Set&lt;Entry&lt;String, HttpSession&gt;&gt; entrySet = userSessionMap.entrySet(); for(Entry&lt;String, HttpSession&gt; entry:entrySet){ HttpSession session = entry.getValue(); log.info("HttpSession " + session.getId() + " calling invalidate"); session.invalidate(); } } </code></pre> <p>and the following is overwritten HttpSessionListener</p> <pre><code>@Override public void sessionDestroyed(HttpSessionEvent se){ HttpSession session = se.getSession(); String id = session.getId(); LoginActionController controller = (LoginActionController) session.getAttribute("userInfo"); log.info("HttpSession " + id + ", LoginActionController " + controller + " is being destroyed..."); if(controller != null){ log.info("User " + controller.getUserName() + " is logged out"); String userName = controller.getUserName(); ServletContext context = session.getServletContext(); Object obj = context.getAttribute("USERS"); if(obj instanceof Map){ Map map = (Map) obj; map.remove(userName); RWFacade rWFacade =(RWFacade)session.getAttribute("rWFacade"); rWFacade.closeFacade(); } } } </code></pre> <p>when run this code </p> <pre><code>session.invalidate(); </code></pre> <p>is not getting executed. I missed anything ? Thanks.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload