I solved this via MyFaces CODI (see below), but my beans are still not accessible for some reason. I think I recognized that that web.xml has webapp version="2.5", in the jboss CDI documentation. I have webapp version="3.0". I wonder if that is the cause.
/*
To change this template, choose Tools | Templates
and open the template in the editor.
*/
package pf;
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
I solved this via MyFaces CODI (see below), but my beans are still not accessible for some reason. I think I recognized that that web.xml has webapp version="2.5", in the jboss CDI documentation. I have webapp version="3.0". I wonder if that is the cause.
/*
*/
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;
import org.apache.myfaces.extensions.cdi.core.api.provider.BeanManagerProvider;
/**
*
*/
@WebListener
public class UserHttpSessionListener implements HttpSessionListener {
@Override
public void sessionCreated(HttpSessionEvent event) { // Do here the job. }
@Override
public void sessionDestroyed(HttpSessionEvent event) {
/*
pf_UsersController userBean = (pf_UsersController) event.getSession().
getAttribute("pf_usersController");
*/
pf_UsersController userBean = null;
try { userBean = BeanManagerProvider.getInstance(). getContextualReference(pf_UsersController.class); } catch (Exception e) {
}
if (userBean != null && userBean.getUser() != null) { String userName = userBean.getUser().getUserName(); System.out.println("UserHttpSessionListener.sessionDestroyed(): " + userName + " session destroyed"); userBean.sessionTimeout(); }
}
}