12 Replies Latest reply on Feb 23, 2009 11:12 AM by nbelaevski

    [high availability] session replication error with richfaces

    six-p4ck

      Hello all.

      Thx to have answer to my older question first about dev in richfaces.

      Now my application is fine (i think) and i can make run my web-app JSF with richfaces and my EJB3.

      I have a ear file who i can deploy easy on one JBOSS server.

      Now i need to make my app in high availability. (sorry a little network but it's for have a good explanation)

      For make this i use 2 way:

      1. I use a apache balancer to do session afinity.
      Sample: one new HTTP request come on my apache balancer (192.168.0.1)
      apache look the session ID and remember than all request with this session ID is routed to the first JBOSS app (192.168.0.100).
      A other new HTTP request, new sessionID, and he forward to other JBOSS app (192.168.0.101)

      If one of my JBOSS app is down, apache send all request to other JBOSS app

      This work fine but i need to do session replication.
      sample: if one of my JBOSS app crash, i dont want the user is disconnected or see error message. He must be switch on other JBOSS app without user see anything.
      i can make this like sample here: http://www.mastertheboss.com/en/jboss-application-server/48-jboss-clustering-web.html

      But when i try to make the same with my appli i have error with richfaces.
      I have no probleme with another appli without richfaces.

      error message:


      type Exception report message description The server encountered an internal error () that prevented it from fulfilling this request.
      exception
      javax.servlet.ServletException: setAttribute: Non-serializable attribute
       javax.faces.webapp.FacesServlet.service(FacesServlet.java:277)
       org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
       org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
       org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:390)
       org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:517)
       org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      root cause
      java.lang.IllegalArgumentException: setAttribute: Non-serializable attribute
       org.jboss.web.tomcat.service.session.ClusteredSession.setAttribute(ClusteredSession.java:555)
       org.apache.catalina.session.StandardSessionFacade.setAttribute(StandardSessionFacade.java:130)
       com.sun.faces.context.SessionMap.put(ExternalContextImpl.java:971)
       com.sun.faces.mgbean.BeanManager$ScopeManager$SessionScopeHandler.handle(BeanManager.java:442)
       com.sun.faces.mgbean.BeanManager$ScopeManager.pushToScope(BeanManager.java:417)
       com.sun.faces.mgbean.BeanManager.createAndPush(BeanManager.java:369)
       com.sun.faces.mgbean.BeanManager.create(BeanManager.java:222)
       com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:88)
       javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
       com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:72)
       org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:45)
       org.apache.el.parser.AstValue.getTarget(AstValue.java:42)
       org.apache.el.parser.AstValue.invoke(AstValue.java:127)
       org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
       org.apache.jasper.el.JspMethodExpression.invoke(JspMethodExpression.java:68)
       javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
       com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
       javax.faces.component.UICommand.broadcast(UICommand.java:387)
       org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:321)
       org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:296)
       org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:253)
       org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:466)
       com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
       com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
       com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
       javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
       org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
       org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
       org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:390)
       org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:517)
       org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)


      I think they are richfaces objet no serializable in session (in my app i just put user and he is serializable). possible?
      Is it possible to make session replication with richfaces?
      If yes, how?


      very thanks.

        • 1. Re: [high availability] session replication error with richf
          nbelaevski

          Hello,

          According to stack trace problem happens because some managed bean is not Serializable. As I can see this happens when you invoke some command components. How does "action" attribute for this component look like? What bean does it refer to?

          • 2. Re: [high availability] session replication error with richf
            six-p4ck

            The error comes when i click to in my login page(:

            <h:commandButton type="submit" value="Login" label="Submit" styleClass="commandButton" id="button1" action="#{pc_Login.doLogin}" />


            In my backing bean:

            public String doLogin() {
             String login = (String) getInputLogin().getValue();
             String password = (String) getInputPassword().getValue();
             String retour = getControleurEJBeanUser().testLogin(login,password);
             if (retour.equals("failure")) {
             addErrorMessage("Wrong login or password");
             }
             return retour;
             }
            


            My EJB controler:
            package speos.controler;
            
            import java.io.InputStream;
            import java.util.Properties;
            
            import javax.faces.context.FacesContext;
            import javax.naming.InitialContext;
            import javax.naming.NamingException;
            
            import speos.sessionweb.SavedInSession;
            import speos.entity.User;
            import speos.session.UserInterface;
            
            public class ControleurEJBeanUser {
            
             protected InitialContext ctx;
             protected UserInterface EJBUser;
             protected SavedInSession sessionSave;
            
             public String testLogin(String user, String password) {
             try {
             User userTryLogin = getEJBUser().testLogin(user, password);
             //System.out.println("User: " + userTryLogin);
             if (userTryLogin == null) {
             return "failure";
             } else {
             // put user in session
             //System.out.println("setUser: " + userTryLogin);
             getSessionSave().setUserSaved(userTryLogin);
             return "success";
             }
             } catch (Exception e) {
             e.printStackTrace();
             return "failure";
             }
             }
            
             public InitialContext getCtx() throws NamingException {
             if (ctx == null) {
             Properties props = new Properties();
             try {
             InputStream is = this.getClass().getResourceAsStream("jndi.properties");
             if (is == null) {
             throw new Exception("No jndi.properties file could be retrieved.");
             }
             props.load(is);
             } catch (Exception e) {
             System.err.println("" + e);
             }
             ctx = new InitialContext(props);
             }
             return ctx;
             }
            
             public UserInterface getEJBUser() throws NamingException {
             if (EJBUser == null) {
             EJBUser = (UserInterface) getCtx().lookup("InputFollowup/UserBean/remote");
             }
             return EJBUser;
             }
            
             public SavedInSession getSessionSave() {
             if (sessionSave == null) {
             FacesContext context = FacesContext.getCurrentInstance();
             sessionSave = (SavedInSession) context.getApplication().getExpressionFactory().createValueExpression(context.getELContext(), "#{savedInSession}", SavedInSession.class).getValue(context.getELContext());
             }
             return sessionSave;
             }
            }
            
            


            And of course my entity User implements Serializable
            public class User implements Serializable
            


            • 3. Re: [high availability] session replication error with richf
              six-p4ck

              And i forgot this:

              import speos.entity.User;
              public class SavedInSession {
               User userSaved;
              
               public User getUserSaved() {
               return userSaved;
               }
              
               public void setUserSaved(User userSaved) {
               this.userSaved = userSaved;
               }
              }
              


              • 4. Re: [high availability] session replication error with richf
                six-p4ck

                Ok need so serializable my SavedInSession class.

                sorry

                • 5. Re: [high availability] session replication error with richf
                  six-p4ck

                  i have always the same even with SavedInSession implements Serializable

                  • 6. Re: [high availability] session replication error with richf
                    nbelaevski

                    Please post stack trace you get.

                    • 7. Re: [high availability] session replication error with richf
                      six-p4ck

                      Without the

                      <distributable/>
                      in web.xml it's work fine;

                      when i add
                      <distributable/>
                      in my web.xml it bug.

                      I see the login page and when i click on login button boum


                      Etat HTTP 500 -

                      type Rapport d'exception

                      message

                      description Le serveur a rencontré une erreur interne () qui l'a empêché de satisfaire la requête.

                      exception

                      javax.servlet.ServletException: "setAttribute": attribut non sérialisable
                      javax.faces.webapp.FacesServlet.service(FacesServlet.java:277)
                      org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
                      org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
                      org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:390)
                      org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:517)
                      pagecode.LogInFilter.doFilter(LogInFilter.java:62)
                      org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

                      cause mère

                      java.lang.IllegalArgumentException: "setAttribute": attribut non sérialisable
                      org.apache.catalina.session.StandardSession.setAttribute(StandardSession.java:1293)
                      org.apache.catalina.session.StandardSession.setAttribute(StandardSession.java:1254)
                      org.apache.catalina.session.StandardSessionFacade.setAttribute(StandardSessionFacade.java:130)
                      com.sun.faces.context.SessionMap.put(ExternalContextImpl.java:971)
                      com.sun.faces.mgbean.BeanManager$ScopeManager$SessionScopeHandler.handle(BeanManager.java:442)
                      com.sun.faces.mgbean.BeanManager$ScopeManager.pushToScope(BeanManager.java:417)
                      com.sun.faces.mgbean.BeanManager.createAndPush(BeanManager.java:369)
                      com.sun.faces.mgbean.BeanManager.create(BeanManager.java:222)
                      com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:88)
                      javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
                      com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:72)
                      org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:45)
                      org.apache.el.parser.AstValue.getTarget(AstValue.java:42)
                      org.apache.el.parser.AstValue.invoke(AstValue.java:127)
                      org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
                      org.apache.jasper.el.JspMethodExpression.invoke(JspMethodExpression.java:68)
                      javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
                      com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
                      javax.faces.component.UICommand.broadcast(UICommand.java:387)
                      org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:321)
                      org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:296)
                      org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:253)
                      org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:466)
                      com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
                      com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
                      com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
                      javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
                      org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
                      org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
                      org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:390)
                      org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:517)
                      pagecode.LogInFilter.doFilter(LogInFilter.java:62)
                      org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)



                      I know it's look like i try to save in session a no serializable thing but all is serialisable and i have the same error when i save nothing in session!!!

                      • 8. Re: [high availability] session replication error with richf
                        six-p4ck

                        I have try without LogInFilter and it's the same mistake

                        • 9. Re: [high availability] session replication error with richf
                          six-p4ck

                          up... and down ^^

                          • 10. Re: [high availability] session replication error with richf
                            nbelaevski

                            Hello,

                            Can you please prepare small project demonstrating the issue? You can send it to me to nbelaevski at exadel dot com.

                            • 11. Re: [high availability] session replication error with richf
                              six-p4ck

                              Ok i can try.

                              But for this project i have use netbean... and EJB3 on DB2.

                              If i do a small demonstration project i use the same (netbean,EJB3 and db2).
                              You probably have to change for make work.

                              it's not a big problem for you?

                              • 12. Re: [high availability] session replication error with richf
                                nbelaevski

                                Ok, please send it to me and I'll check.