3 Replies Latest reply on May 9, 2016 7:12 AM by carcara

    Attribute in HttpSession not replicate Cluster

    carcara

      Hi,


      My application is running in cluster with two nodes.

      Was built with JSF(with primefaces)+JPA+EJB+hibernate and so one.

       

      When logging in application I´m setting attribute in http session. For some reason, when I switch over another node in the cluster, the viewExpiredSession is launched.

      In debbug, i saw the attribute is returning null.

       

      My web.xml is configured with <distributable />, and when I´m setting assigning attribute in session I do that:

       

      public static void setSessionValue(String name, Object obj) throws Exception {

        final FacesContext facesContext = FacesContext.getCurrentInstance();

        if (facesContext != null) {

        final HttpSession session = (HttpSession) facesContext.getExternalContext().getSession(false);

        if (session != null) {

        session.setAttribute(name, obj);

        } else {

        throw new SessaoWebExpiradaException();

        }

       

       

      And i retrieve the atribute like this:

       

      public void doFilter(final ServletRequest req, final ServletResponse resp, final FilterChain filterChain)

        throws IOException, ServletException {

        if (this.enabled) {

        final HttpServletRequest request = (HttpServletRequest) req;

        final LoginInformationHelper loginInformationHelper = (LoginInformationHelper) request.getSession()

        .getAttribute(LOGIN_INFORMATION_HELPER);

        final String requestURI = request.getRequestURI();

        final String contextPath = request.getContextPath();

       

      Thanks.