0 Replies Latest reply on Dec 2, 2005 11:45 AM by Kurt De Wit

    EJB fail-over

    Kurt De Wit Newbie


      I have the following situation:
      1. Two JBoss 4.0.2 servers running on WinXP PRO and Suse 9.2 configured as a cluster using the all configuration
      2. I create a very simple EAR containing a stateful session bean with the clusterable attribute set in the deployment descriptor and deployed by farming to both application servers.
      3. A simple J2SE client application (command line) that connects to the session bean and calls a string returning "Hello-World"-like method.

      Both members in the cluster are aware of eachother because when the client application creates several instances to the session bean, they are load-balanced between the two servers.

      The problem occures when I shutdown one of both instances of Tomcat. Connections made to this server get lost although I would like to use the remaining to process the requests. It seems that fail-over is not working for my configuration. Does anyone know some good documents/examples to achieve this kind of behaviour? I really like JBoss so it would be a pitty to notice that such stuff would not be possible ;-)

      Thanks for the advise !!!!


      The client application

      package client;
      import java.util.*;
      import javax.naming.*;
      import javax.rmi.*;
      import server.ejb.*;
      public class ClusterClient {
       public ClusterClient() {
       for(int j = 0 ; j < 5 ; j++){
       Runnable runner = new ClusterClientRunner();
       Thread thread = new Thread(runner, "Runner " + j);
       }catch(InterruptedException e){
       private class ClusterClientRunner implements Runnable{
       public void run(){
       System.out.println(Thread.currentThread().getName() + " started.");
       Properties props = new Properties();
       // ",");
       Context ctx = new InitialContext(props);
       StatefullSessionRemoteHome home = (StatefullSessionRemoteHome)
       StatefullSessionRemote bean = home.create();
       for(int i = 0 ; i < 20 ; i++){
       System.out.println(Thread.currentThread().getName() + " triggering with ID = " + i);
       bean.executedAt(Thread.currentThread().getName() + " triggering with ID = " + i);
       }catch(InterruptedException e){}
       }catch(Exception ex){
       System.out.println(Thread.currentThread().getName() + " completed.");
       public static void main(String[] args) {
       new ClusterClient();

      The session bean's code
      package server.ejb;
      import javax.ejb.*;
      import javax.naming.*;
      public class StatefullSessionBean implements javax.ejb.SessionBean, server.ejb.StatefullSessionRemoteBusiness, server.ejb.StatefullSessionLocalBusiness {
       private javax.ejb.SessionContext context;
       private static int counter;
       public void setSessionContext(javax.ejb.SessionContext aContext) {
       context = aContext;
       public void ejbActivate() {
       public void ejbPassivate() {
       public void ejbRemove() {
       public void ejbCreate() {
       public String showMessage() {
       StringBuffer buffer = new StringBuffer();
       buffer.append("Bean executed at : " + (String)System.getProperty("server"));
       System.out.println(counter + " == " + buffer.toString());
       return buffer.toString();
       public void executedAt(java.lang.String location) {
       System.out.println("Triggered by : " + location);

      The deployment descriptor
      <?xml version="1.0" encoding="UTF-8"?>