11 Replies Latest reply on Apr 20, 2007 3:22 PM by Brian Stansberry

    Clustering and Load Balancing in Jboss-4.0.2 using Apache-2.

    C Kishor Newbie

      I have a simple war and jar files in Jboss-4.0.2. I am accessing this through Apache-2.0.59.
      Configured throudh mod_jk from the site http://wiki.jboss.org/wiki/Wiki.jsp?page=UsingMod_jk1.2WithJBoss
      After completing the configurtion i started all, and node1. Both started nicely....
      but when i access my login screen...i got the following exception...Please provide me the suggestions....

      _0_2 date=200505022023)] Started in 3m:2s:922ms
      14:06:46,437 INFO [STDOUT] java.io.NotSerializableException: org.apache.catalina.session.StandardSessionFacade
      14:06:46,437 INFO [STDOUT] at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1054)
      14:06:46,437 INFO [STDOUT] at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1332)
      14:06:46,437 INFO [STDOUT] at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1304)
      14:06:46,437 INFO [STDOUT] at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1247)
      14:06:46,437 INFO [STDOUT] at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1052)
      14:06:46,437 INFO [STDOUT] at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:278)
      14:06:46,437 INFO [STDOUT] at java.util.HashMap.writeObject(HashMap.java:978)
      14:06:46,437 INFO [STDOUT] at sun.reflect.GeneratedMethodAccessor70.invoke(Unknown Source)
      14:06:46,453 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      14:06:46,453 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:324)
      14:06:46,453 INFO [STDOUT] at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:809)
      14:06:46,453 INFO [STDOUT] at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1296)
      14:06:46,453 INFO [STDOUT] at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1247)
      14:06:46,453 INFO [STDOUT] at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1052)
      14:06:46,468 INFO [STDOUT] at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1332)
      14:06:46,468 INFO [STDOUT] at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1304)
      14:06:46,468 INFO [STDOUT] at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1247)
      14:06:46,468 INFO [STDOUT] at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1052)
      14:06:46,484 INFO [STDOUT] at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:278)
      14:06:46,500 INFO [STDOUT] at org.jboss.invocation.MarshalledValue.(MarshalledValue.java:57)
      14:06:46,500 INFO [STDOUT] at org.jboss.web.tomcat.tc5.session.JBossCacheService.getMarshalledValue(JBossCacheService.java:538)
      14:06:46,500 INFO [STDOUT] at org.jboss.web.tomcat.tc5.session.JBossCacheService.putSession(JBossCacheService.java:155)
      14:06:46,500 INFO [STDOUT] at org.jboss.web.tomcat.tc5.session.SessionBasedClusteredSession.processSessionRepl(SessionBasedClusteredSession.java:161)
      14:06:46,593 INFO [STDOUT] at org.jboss.web.tomcat.tc5.session.JBossCacheManager.processSessionRepl(JBossCacheManager.java:475)
      14:06:46,593 INFO [STDOUT] at org.jboss.web.tomcat.tc5.session.JBossCacheManager.storeSession(JBossCacheManager.java:256)
      14:06:46,593 INFO [STDOUT] at org.jboss.web.tomcat.tc5.session.InstantSnapshotManager.snapshot(InstantSnapshotManager.java:38)
      14:06:46,593 INFO [STDOUT] at org.jboss.web.tomcat.tc5.session.ClusteredSessionValve.invoke(ClusteredSessionValve.java:91)
      14:06:46,593 INFO [STDOUT] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
      14:06:46,593 INFO [STDOUT] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
      14:06:46,625 INFO [STDOUT] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
      14:06:46,625 INFO [STDOUT] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
      14:06:46,625 INFO [STDOUT] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
      14:06:46,625 INFO [STDOUT] at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:307)
      14:06:46,640 INFO [STDOUT] at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:385)
      14:06:46,640 INFO [STDOUT] at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:748)
      14:06:46,640 INFO [STDOUT] at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:678)
      14:06:46,656 INFO [STDOUT] at org.apache.jk.common.SocketConnection.runIt(ChannelSocket.java:871)
      14:06:46,656 INFO [STDOUT] at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
      14:06:46,656 INFO [STDOUT] at java.lang.Thread.run(Thread.java:534)

        • 1. Re: Clustering and Load Balancing in Jboss-4.0.2 using Apach
          Brian Stansberry Master

          Some code is calling HttpSession.setAttribute and passing a non-serializable attribute as the attribute value. In this case it looks to be a reference to the session itself.

          Suggest you write an javax.servlet.http.HttpSessionAttributeListener implementation and have it analyze (i.e. try to serialize) values as they are passed into the session. This will help you identify what code is passing in the offending value.

          • 2. Re: Clustering and Load Balancing in Jboss-4.0.2 using Apach
            C Kishor Newbie

            Thanks alot for replying. i think this would be a nice suggestion, Stans. Will try this and get back to u.

            -Kishor.

            • 3. Re: Clustering and Load Balancing in Jboss-4.0.2 using Apach
              C Kishor Newbie

              I tried but not solved. My login.jsp contains a class which is Serialized then also giving the above problem when i say localhost/timbermine

              Following are the steps which i followed...

              1. Downloaded a fresh jboss-4.0.2.
              2. copied all and saved as node1
              3. Followed the steps given in site...http://wiki.jboss.org/wiki/Wiki.jsp?page=UsingMod_jk1.2WithJBoss
              4. Added project path in the uriworkermap.properties.
              5. All is running on 8080 and node1 is on 8180 ports.

              My jar and war are deploying fine on both the server. Started the Apache server and when i say localhost/timbermine displays the above error.
              As i told my login.jsp contains a class which is Serialized and i am not setting any thing in the session in login.jsp file.

              Thanks in advance.
              -Kishor

              • 4. Re: Clustering and Load Balancing in Jboss-4.0.2 using Apach
                C Kishor Newbie

                And also when i set tag in web.xml then it displays that NotSerializableException message...The above message.

                I again tried step by step..i found here. Whar could be the reason?
                -Kishor.

                • 5. Re: Clustering and Load Balancing in Jboss-4.0.2 using Apach
                  Brian Stansberry Master

                  Did you create and deploy the HttpSessionAttributeListener?

                  • 6. Re: Clustering and Load Balancing in Jboss-4.0.2 using Apach
                    C Kishor Newbie

                    Yes, I created HttpSessionAttributeListener. It is displaying the names and values what ever i set in the session. In my case i am setting 2 things in the session in login page.

                    1. DMSession class which extends UserSession class which implements serializable.
                    2. A boolean variable in the DMSession's object as true.

                    There is only HTML code to take user id and password for inputs.
                    I started all on 8080 and node1 on 8180...Started nicely. Tested web-console displays both when refreshed.

                    when i say localhost/timbermine, First request goes to all server. Value of boolean set in the session is true....
                    and when i enter details and submit, the second request goes to node1 now the value of boolean variable is false in node1 since the first request goes to all server.....and displays the following error in node1....

                    The boolean variable i am setting in the session is not replicating in the node1...

                    In this first 2 lines are the values set in the session..

                    10:21:23,976 INFO [STDOUT] [Sess Add] javax.servlet.http.HttpSessionBindingEvent[source=org.apache.catalina.session.StandardSessionFacade@9212f4]: session_manager=dm.web.utils.DmWebSession@1a755e
                    10:21:23,992 INFO [STDOUT] [Sess Add] javax.servlet.http.HttpSessionBindingEvent[source=org.apache.catalina.session.StandardSessionFacade@9212f4]: ISFROMLOGIN=true

                    10:21:24,039 INFO [STDOUT] java.io.NotSerializableException: org.apache.catalina.session.StandardSessionFacade
                    10:21:24,039 INFO [STDOUT] at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1054)
                    10:21:24,039 INFO [STDOUT] at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1332)
                    10:21:24,039 INFO [STDOUT] at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1304)
                    10:21:24,039 INFO [STDOUT] at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1247)
                    10:21:24,039 INFO [STDOUT] at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1052)
                    10:21:24,039 INFO [STDOUT] at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:278)
                    10:21:24,054 INFO [STDOUT] at java.util.HashMap.writeObject(HashMap.java:978)
                    10:21:24,054 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                    10:21:24,054 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                    10:21:24,054 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                    10:21:24,054 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:324)
                    10:21:24,070 INFO [STDOUT] at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:809)
                    10:21:24,070 INFO [STDOUT] at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1296)
                    10:21:24,070 INFO [STDOUT] at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1247)
                    10:21:24,070 INFO [STDOUT] at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1052)
                    10:21:24,070 INFO [STDOUT] at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1332)
                    10:21:24,070 INFO [STDOUT] at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1304)
                    10:21:24,085 INFO [STDOUT] at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1247)
                    10:21:24,085 INFO [STDOUT] at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1052)
                    10:21:24,085 INFO [STDOUT] at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:278)
                    10:21:24,085 INFO [STDOUT] at org.jboss.invocation.MarshalledValue.(MarshalledValue.java:57)
                    10:21:24,085 INFO [STDOUT] at org.jboss.web.tomcat.tc5.session.JBossCacheService.getMarshalledValue(JBossCacheService.java:538)
                    10:21:24,101 INFO [STDOUT] at org.jboss.web.tomcat.tc5.session.JBossCacheService.putSession(JBossCacheService.java:155)
                    10:21:24,117 INFO [STDOUT] at org.jboss.web.tomcat.tc5.session.SessionBasedClusteredSession.processSessionRepl(SessionBasedClusteredSession.java:161)
                    10:21:24,117 INFO [STDOUT] at org.jboss.web.tomcat.tc5.session.JBossCacheManager.processSessionRepl(JBossCacheManager.java:475)
                    10:21:24,117 INFO [STDOUT] at org.jboss.web.tomcat.tc5.session.JBossCacheManager.storeSession(JBossCacheManager.java:256)
                    10:21:24,117 INFO [STDOUT] at org.jboss.web.tomcat.tc5.session.InstantSnapshotManager.snapshot(InstantSnapshotManager.java:38)
                    10:21:24,117 INFO [STDOUT] at org.jboss.web.tomcat.tc5.session.ClusteredSessionValve.invoke(ClusteredSessionValve.java:91)
                    10:21:24,117 INFO [STDOUT] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
                    10:21:24,117 INFO [STDOUT] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
                    10:21:24,117 INFO [STDOUT] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
                    10:21:24,117 INFO [STDOUT] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
                    10:21:24,117 INFO [STDOUT] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
                    10:21:24,132 INFO [STDOUT] at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:307)
                    10:21:24,132 INFO [STDOUT] at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:385)
                    10:21:24,132 INFO [STDOUT] at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:748)
                    10:21:24,132 INFO [STDOUT] at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:678)
                    10:21:24,132 INFO [STDOUT] at org.apache.jk.common.SocketConnection.runIt(ChannelSocket.java:871)
                    10:21:24,148 INFO [STDOUT] at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
                    10:21:24,148 INFO [STDOUT] at java.lang.Thread.run(Thread.java:534)

                    • 7. Re: Clustering and Load Balancing in Jboss-4.0.2 using Apach
                      Brian Stansberry Master

                      Your DmWebSession class must be your problem then. Saying it implements Serializable is insufficient; all of its fields must also implement Serializable or be declared transient. Somewhere in the DmWebSession's object graph there is a non-transient reference to the session itself (aka org.apache.catalina.session.StandardSessionFacade). StandardSessionFacade isn't serializable, so that won't work.

                      • 8. Re: Clustering and Load Balancing in Jboss-4.0.2 using Apach
                        C Kishor Newbie

                        Actually DMWebSession which extends UserSession is having inner classes. They are also Serialized. There are 4 to 5 inner classes and each inner class contains public static final String variables.

                        Following is my DMWebSession class....I am creating the object of this and calling from login.jsp and settirng true or false.

                        ----------DMWebSession.java-----------
                        public class DmWebSession extends UserSession {

                        private HttpSession session_;
                        private static final String SESSION_MGR = "SESSION_MANAGER";

                        public static DmWebSession getDmWebSession(HttpSession session) {
                        DmWebSession sessionMgr = null;

                        sessionMgr = (DmWebSession) session.getAttribute(SESSION_MGR);
                        if (sessionMgr == null) {
                        sessionMgr = new DmWebSession(session);
                        }
                        return sessionMgr;
                        }

                        private DmWebSession(HttpSession session) {
                        session.setAttribute(SESSION_MGR, this);
                        session_ = session;
                        }

                        protected Object getAttribute(String key) {
                        return session_.getAttribute(key);
                        }

                        protected void setAttribute(String key, Object value) {
                        session_.setAttribute(key, value);
                        }

                        protected void removeAttribute(String key) {
                        session_.removeAttribute(key);
                        }

                        public void invalidateSession() {
                        session_.invalidate();
                        session_ = null;
                        }

                        public void removeSelectedItems() {
                        //This class is also Serialized
                        UtilitiesBean util = new UtilitiesBean();

                        util.cleanSession(session_);
                        }

                        }
                        The classes which are imported is it necessary they should also be Serialized ?

                        • 9. Re: Clustering and Load Balancing in Jboss-4.0.2 using Apach
                          Brian Stansberry Master



                          "bstansberry@jboss.cm" wrote:
                          Saying it implements Serializable is insufficient; all of its fields must also implement Serializable or be declared transient. Somewhere in the DmWebSession's object graph there is a non-transient reference to the session itself (aka org.apache.catalina.session.StandardSessionFacade). StandardSessionFacade isn't serializable, so that won't work.


                          And here that ref is:

                          public class DmWebSession extends UserSession {
                          
                           private HttpSession session_;


                          HttpSession is an interface; the actual class of the object is StandardSessionFacade. You can't hold a ref to the session in a session attribute.

                          • 10. Re: Clustering and Load Balancing in Jboss-4.0.2 using Apach
                            C Kishor Newbie

                            GREAT solution sir...it works....As per your suggestions, i commented a line in the code. Now its not displaying the error.

                            I changed CacheMode to REPL_SYNC in tc5-cluster-service.xml to check whether session is replicating or not. It waits for sometime and displays following in node1....

                            14:01:53,218 WARN [ReplicationInterceptor] runPreparePhase() failed. Transaction is marked as rolled back
                            org.jboss.cache.lock.TimeoutException: rsp=sender=kishor:2283, retval=null, received=false, suspected=false
                            at org.jboss.cache.TreeCache.callRemoteMethods(TreeCache.java:2186)
                            at org.jboss.cache.TreeCache.callRemoteMethods(TreeCache.java:2208)
                            at org.jboss.cache.interceptors.ReplicationInterceptor.runPreparePhase(ReplicationInterceptor.java:485)
                            at org.jboss.cache.interceptors.ReplicationInterceptor$SynchronizationHandler.beforeCompletion(ReplicationInterceptor.java:389)
                            at org.jboss.cache.interceptors.OrderedSynchronizationHandler.beforeCompletion(OrderedSynchronizationHandler.java:77)
                            at org.jboss.tm.TransactionImpl.doBeforeCompletion(TransactionImpl.java:


                            What could be the reason? Done the settings are per the site...
                            http://www.jboss.org/developers/projects/jboss/tc5-clustering.html

                            waiting for reply..

                            • 11. Re: Clustering and Load Balancing in Jboss-4.0.2 using Apach
                              Brian Stansberry Master

                              This isn't going to solve your problem, but first, in the cache config file, make sure SyncReplTimeout is at least of few seconds longer than LockAcquisitionTimeout.

                              If you do that, and you get the same exception (look at the details of the error message; it's important) then you need to start by debugging the connectivity between the servers. See http://wiki.jboss.org/wiki/Wiki.jsp?page=TestingJBoss
                              and http://www.jgroups.org/javagroupsnew/docs/newuser/node6.html.

                              If you get an exception that talks about failure to acquire a lock, then make sure sticky sessions are working correctly.