Now I have decided. Thanks to smallworld for pointing me in the right direction. It happened that we cached the remote interfaces obtained from the jndi search. Now, from what I understand, this remote interface points to only one specific server from the cluster. (We thought that the remote interface would be smart enough to determine that the server was down. It seems that the smartness is somewhere with the original context when you perform the search). Therefore, as soon as the server is down, any ejb call made for this remote interface will connect to the server that was down. Therefore, to solve this problem, we stopped caching the remote interface and each time we search every time we need the services of this EJB. If any server does not work, the search will return the remote interface of the server that is up and running. With this cluster works flawlessly! So guys, your code should look something like this:
// Some where at class level we have the following map declared private static final Map remoteEJBHashMap = new HashMap(100, 0.9f); public static final <T> T getEJBInterface(String jndiLookupName) { String jndiName = jndiLookupMap.get(jndiLookupName); T ejbInterface = null; //T ejbInterface = (T) remoteEJBHashMap.get(jndiLookupName); //if (ejbInterface == null) { try { ejbInterface = (T) ctx.lookup(jndiName); } catch (NamingException e) { throw new RuntimeException(e); } //remoteEJBHashMap.put(jndiLookupName, ejbInterface); //} return ejbInterface; }
Commented lines are the ones that caused the problem. Now the only thing left for the study is the best solution for this, if any.
source share