javajsf-2jboss7.xsession-timeoutphaselistener

JSF - SessionExpirationPhaseListener on a JBoss Cluster


we are getting this exception:

TimeoutException: JBAS010213: Cannot acquire lock default-host/...

We are using this PhaseListener in our web application to capture session timeout on ajax requests and redirect to index (we are suspecting this could be related, but we dont know):

public class SessionExpirationPhaseListener implements PhaseListener {

@Override
public PhaseId getPhaseId() {

    return PhaseId.RESTORE_VIEW;

}

@Override
public void beforePhase(PhaseEvent event) {
}

@Override
public void afterPhase(PhaseEvent event) {
    FacesContext context = FacesContext.getCurrentInstance();
    HttpServletRequest httpRequest = (HttpServletRequest) context.getExternalContext().getRequest();
    if (httpRequest.getRequestedSessionId() != null && !httpRequest.isRequestedSessionIdValid()) {
        String facesRequestHeader = httpRequest.getHeader("Faces-Request");
        boolean isAjaxRequest = facesRequestHeader != null && facesRequestHeader.equals("partial/ajax");
        // navigate to home page only for ajax requests
        if (isAjaxRequest) {
            ConfigurableNavigationHandler handler = (ConfigurableNavigationHandler) context.getApplication().getNavigationHandler();
            handler.performNavigation("home");
        }
    }
}

}

We are running over a JBoss cluster with 2 nodes (mod_cluster + apache) and have SSO enabled. Do you guys know what could be wrong? Or at least point us to the right direction?

Thanks, Regards.


Solution

  • I believe the problem here are to two nodes trying to get access to the same session, where one node is handling an incoming request, and the second node is performing a session expiration.

    Check cookies are being sent in your ajax call, a possible problem is the execution of phase listener in the node that not be owner of session.

    EDIT:

    Exist this bug maybe associated to this problem: https://bugzilla.redhat.com/show_bug.cgi?id=993041