7 Replies Latest reply on Jan 4, 2006 10:48 AM by Marco Sigismondi

    clustering & database

    Marco Sigismondi Newbie

      Hi,
      I'm working on an application based on a stateful session ejb, and an entity ejb.
      I have a 2 nodes cluster, where I deploy my application (putting the .ear file in the server/all/farm directory in one of the nodes, and jboss replicates the package on the other node).

      The problem is: when I use the application on the first node, interacting with the entity ejb and storing new data (which is saved in the all/data/hypersonic folder), then the second node is not updated with new data. It seems that there is a different database on each node.
      How can I share the database inside the cluster?


      Thanks

        • 1. Re: clustering & database
          Brian Stansberry Master

          Hypersonic is an in-process database (i.e. runs inside the JVM that runs a JBoss instance).

          You should use an external database. There are lots of open source ones (mysql, postgres, derby).

          • 2. Re: clustering & database
            Marco Sigismondi Newbie

            So, how can I mantain a session state for my application among the nodes?

            Should I use http clustering?

            • 3. Re: clustering & database
              Jerry Gauthier Apprentice

              As noted, you can store your data in a common database so that it's accessible from each node.

              You can also store your data in a replicated store in a JBoss cluster. Possibilities include JBossCache (using replication), HAJNDI and DistributedState.

              • 4. Re: clustering & database
                Marco Sigismondi Newbie

                I'm working with jboss 3.2.5 for windows (with the 'all' config) and, if possibile, I would prefer to use no external software (like an external database).

                I'm a newbie to jboss (in particolar, with clustering)

                I've tried with:

                -HAJNDI
                I modified the InitialContext() method in the servlet, changing the port (1100 instead of 1099). I deployed the entire application (ejbs+servlet) on node1, and only the servlet on node2.
                But, using the servlet on node2, when it tries to connect to the session bean, it stops with this error:

                exception
                javax.servlet.ServletException: Servlet execution threw an exception

                root cause
                java.lang.NoClassDefFoundError: No ClassLoaders found for: myejbapplication.ejb.SessionBeanHome
                myejbapplication.web.ApplicationServlet.doPost(ApplicationServlet.java:79)
                javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
                javax.servlet.http.HttpServlet.service(HttpServlet.java:810)


                Why didn't it find the ejbs on node1 using HA-JNDI? :(


                -HTTP Clustering
                Following the instructions found here: http://docs.jboss.org/jbossas/jboss4guide/r4/html/cluster.chapt.html#clustering-http, I tried to install Apache with the mod-jk.so module, but I'm not sure about its configuration... Do I have to put Apache on both nodes, or only on one? Also, I can't configurate Jboss because, when I insert the line true in the server/all/deploy/jbossweb-tomcat50.sar/META-INF/jboss-service.xml file, Jboss says it doesn't know the attribute UseJK...



                I think it's all very difficult for me... :(
                Which is the easiest method to mantain a session state between the two nodes for my application?
                Can you please explain me how to use and configure it in plain words?

                Thanks a lot.

                • 5. Re: clustering & database
                  Ben Wang Master

                  1. http session repl is the easiest one.
                  2. Use 3.2.7 and later

                  • 6. Re: clustering & database
                    Marco Sigismondi Newbie

                    I downloaded and installed jboss-4.0.3SP1.
                    I installed, on the first node, Apache with the mod_jk module, configurating it with my two nodes addresses in the conf/worker.properties file (I called my nodes "node1" and "node2"). I also configured Jboss with this instructions: http://docs.jboss.org/jbossas/jboss4guide/r4/html/cluster.chapt.html#clustering-http-jboss
                    I've started Apache and then Jboss on node1.
                    It says:


                    ...
                    16:38:19,828 INFO [TreeCache] setting cluster properties from xml to: UDP(ip_mcast=true;ip_ttl=8;loopback=false;mcast_addr=230.1.2.7;mcast_port=45577;mcast_recv_buf_size=80000;mcast_send_buf_size=150000;ucast_recv_buf_size=80000;ucast_send_buf_size=150000):PING(down_thread=false;num_initial_members=3;timeout=2000;up_thread=false):MERGE2(max_interval=20000;min_interval=10000):FD_SOCK:VERIFY_SUSPECT(down_thread=false;timeout=1500;up_thread=false):pbcast.NAKACK(down_thread=false;gc_lag=50;max_xmit_size=8192;retransmit_timeout=600,1200,2400,4800;up_thread=false):UNICAST(down_thread=false;min_threshold=10;timeout=600,1200,2400;window_size=100):pbcast.STABLE(desired_avg_gossip=20000;down_thread=false;up_thread=false):FRAG(down_thread=false;frag_size=8192;up_thread=false):pbcast.GMS(join_retry_timeout=2000;join_timeout=5000;print_local_addr=true;shun=true):pbcast.STATE_TRANSFER(down_thread=true;up_thread=true)
                    16:38:20,093 INFO [TreeCache] interceptor chain is:
                    class org.jboss.cache.interceptors.CallInterceptor
                    class org.jboss.cache.interceptors.LockInterceptor
                    class org.jboss.cache.interceptors.UnlockInterceptor
                    class org.jboss.cache.interceptors.ReplicationInterceptor
                    16:38:20,093 INFO [TreeCache] cache mode is REPL_ASYNC
                    ...
                    16:38:22,250 INFO [TreeCache] viewAccepted(): new members: [37.255.132.19:2097]
                    16:38:22,265 INFO [TreeCache] state could not be retrieved (must be first member in group)
                    16:38:22,265 INFO [TreeCache] new cache is null (maybe first member in cluster)
                    ...



                    Then I deployed on node1 my application, and Jboss says:


                    16:39:31,562 INFO [EARDeployer] Init J2EE application: file:/C:/Programmi/jboss-4.0.3SP1/server/all/deploy/AddressbookApp.ear
                    16:39:33,078 INFO [EjbModule] Deploying AddressBookEJB
                    16:39:34,031 INFO [EjbModule] Deploying GestioneAddressBookEJB
                    16:39:35,203 INFO [ProxyFactory] Bound EJB Home 'AddressBookEJB' to jndi 'AddressBookHome'
                    16:39:38,250 INFO [STDOUT] CLASSPATH component C:\Programmi\Sun\AppServer\jdk\jre\lib\ext\dnsns.jar: java.util.zip.ZipException: invalid CEN header (bad signature)
                    16:39:38,468 INFO [ProxyFactory] Bound EJB Home 'GestioneAddressBookEJB' to jndi 'GestioneAddressBookHome'
                    16:39:38,468 INFO [EJBDeployer] Deployed: file:/C:/Programmi/jboss-4.0.3SP1/server/all/tmp/deploy/tmp25345AddressbookApp.ear-contents/AddressbookEJB.jar
                    16:39:38,703 INFO [TomcatDeployer] deploy, ctxPath=/addressbook, warUrl=.../tmp/deploy/tmp25345AddressbookApp.ear-contents/AddressbookWeb-exp.war/
                    16:39:39,703 INFO [JBossCacheManager] init(): replicationGranularity_ is 0 and invaldateSessionPolicy is 2
                    16:39:39,906 INFO [JBossCacheManager] Starting JBossManager
                    16:39:39,953 INFO [JBossCacheManager] We are using mod_jk(2) for load-balancing. Will add JvmRouteValve.
                    16:39:40,296 INFO [EARDeployer] Started J2EE application: file:/C:/Programmi/jboss-4.0.3SP1/server/all/deploy/AddressbookApp.ear



                    Then I launched Jboss on node2:


                    ...
                    17:20:37,656 INFO [TreeCache] setting cluster properties from xml to: UDP(ip_mcast=true;ip_ttl=8;loopback=false;mcast_addr=230.1.2.7;mcast_port=45577;mcast_rec
                    v_buf_size=80000;mcast_send_buf_size=150000;ucast_recv_buf_size=80000;ucast_send_buf_size=150000):PING(down_thread=false;num_initial_members=3;timeout=2000;up_t
                    hread=false):MERGE2(max_interval=20000;min_interval=10000):FD_SOCK:VERIFY_SUSPECT(down_thread=false;timeout=1500;up_thread=false):pbcast.NAKACK(down_thread=fals
                    e;gc_lag=50;max_xmit_size=8192;retransmit_timeout=600,1200,2400,4800;up_thread=false):UNICAST(down_thread=false;min_threshold=10;timeout=600,1200,2400;window_si
                    ze=100):pbcast.STABLE(desired_avg_gossip=20000;down_thread=false;up_thread=false):FRAG(down_thread=false;frag_size=8192;up_thread=false):pbcast.GMS(join_retry_t
                    imeout=2000;join_timeout=5000;print_local_addr=true;shun=true):pbcast.STATE_TRANSFER(down_thread=true;up_thread=true)
                    17:20:37,812 INFO [TreeCache] interceptor chain is:
                    class org.jboss.cache.interceptors.CallInterceptor
                    class org.jboss.cache.interceptors.LockInterceptor
                    class org.jboss.cache.interceptors.UnlockInterceptor
                    class org.jboss.cache.interceptors.ReplicationInterceptor
                    17:20:37,812 INFO [TreeCache] cache mode is REPL_ASYNC
                    ...
                    17:20:40,015 INFO [TreeCache] viewAccepted(): new members: [SIGIP4:2097, 37.255.132.18:1074]
                    17:20:40,093 INFO [TreeCache] received the state (size=192 bytes)
                    17:20:40,109 INFO [TreeCache] transient state: 140 bytes
                    17:20:40,109 INFO [TreeCache] setting transient state
                    17:20:40,140 INFO [TreeCache] locking the old tree
                    17:20:40,156 INFO [TreeCache] locking the old tree was successful
                    17:20:40,156 INFO [TreeCache] setting the transient state was successful
                    17:20:40,156 INFO [TreeCache] forcing release of all locks in old tree
                    17:20:40,156 INFO [TreeCache] state was retrieved successfully (in 141 milliseconds)
                    ...



                    ...and, on node1:


                    17:20:21,203 INFO [DefaultPartition] New cluster view for partition DefaultPartition (id: 1, delta: 1) : [37.255.132.19:1099, 37.255.132.18:1099]
                    17:20:21,203 INFO [DefaultPartition] I am (37.255.132.19:1099) received membershipChanged event:
                    17:20:21,203 INFO [DefaultPartition] Dead members: 0 ([])
                    17:20:21,203 INFO [DefaultPartition] New Members : 1 ([37.255.132.18:1099])
                    17:20:21,203 INFO [DefaultPartition] All Members : 2 ([37.255.132.19:1099, 37.255.132.18:1099])
                    17:20:41,203 INFO [TreeCache] viewAccepted(): new members: [37.255.132.19:2097, CAMP4:1074]
                    17:20:41,250 INFO [TreeCache] locking the tree to obtain transient state
                    17:20:41,265 INFO [TreeCache] returning the transient state (140 bytes)



                    Then, I deployed my application (the complete .ear package with both servlet and ejbs, as on node1):


                    17:24:39,875 INFO [EARDeployer] Init J2EE application: file:/C:/Programmi/jboss-4.0.3SP1/server/all/deploy/AddressbookApp.ear
                    17:24:40,593 INFO [EjbModule] Deploying AddressBookEJB
                    17:24:40,890 INFO [EjbModule] Deploying GestioneAddressBookEJB
                    17:24:42,937 INFO [ProxyFactory] Bound EJB Home 'AddressBookEJB' to jndi 'AddressBookHome'
                    17:24:45,421 INFO [ProxyFactory] Bound EJB Home 'GestioneAddressBookEJB' to jndi 'GestioneAddressBookHome'
                    17:24:45,421 INFO [EJBDeployer] Deployed: file:/C:/Programmi/jboss-4.0.3SP1/server/all/tmp/deploy/tmp59685AddressbookApp.ear-contents/AddressbookEJB.jar
                    17:24:45,515 INFO [TomcatDeployer] deploy, ctxPath=/addressbook, warUrl=.../tmp /deploy/tmp59685AddressbookApp.ear-contents/AddressbookWeb-exp.war/
                    17:24:45,718 INFO [JBossCacheManager] init(): replicationGranularity_ is 0 and invaldateSessionPolicy is 2
                    17:24:45,765 INFO [JBossCacheManager] Starting JBossManager
                    17:24:45,781 INFO [JBossCacheManager] We are using mod_jk(2) for load-balancing. Will add JvmRouteValve.
                    17:24:45,859 INFO [EARDeployer] Started J2EE application: file:/C:/Programmi/jboss-4.0.3SP1/server/all/deploy/AddressbookApp.ear



                    The problem is: the session state isn't replicated. When I use my application (and store some data in the entity ejb) on node1, then it's not replicated on node2. In facts, using the application on node2, I have the same situation as the initial database state (modified data on node1 is not replicated on node2).

                    I see a far light at the end of the tunnel... but I'm still inside! :(

                    What's wrong??? Did I miss some passages?

                    Thanks a lot.