Hello, dear experts.
We have the following problem:
In a clustered SAP WAS SS9 on Win 2K/Oracle/JDK 1.4.2_07, if a server in the cluster is shut down its JNDI entries are still visible by other servers' initial context lookup calls.
Piece of code to reproduce is as follows:
LookupTest.java:
package lookuptest;
import javax.naming.*;
import java.util.*;
public class LookupTest {
private static InitialContext ctx=null;
static {
final Properties props=new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sap.engine.services.jndi.InitialReplicatingContextFactoryImpl");
props.put("Replicate","true");
props.put("clear_cache","true");
try {
ctx=new InitialContext(props);
} catch (NamingException e) {
e.printStackTrace();
}
}
public LookupTest() {
}
public static synchronized String get(String name) throws NamingException {
return (String) ctx.lookup(name);
}
public static synchronized void put(String name, String value) throws NamingException, NameAlreadyBoundException {
ctx.bind(name,value);
}
}
// from JSP
<%
String name=null;
try {
name=LookupTest.get("test");
out.prinltn("Found!");
} catch (NamingException e) {
out.prinltn("Not Found!");
// not found
try {
LookupTest.put("test","test");
} catch (NameAlreadyBoundException e) {
}
}
%>
To reproduce:
Start up a cluster.
Run JSP from both servers in a cluster.
Shut down the SAP WAS server on the node that returned Not Found!.
Run JSP from another server - Found appears, although the originating server went down.
I would really appreciate any comments or suggestions.
Regards,
-Yuri
In case someone else needs this here is a workaround: In order to solve our problem we've implemented a refresh algorythm ("leasing" strategy) which keeps the entry "fresh" (or leased) for a certain period of time by a server-side timer thread. If server stops refreshing it we assume it's down and clean the entry from JNDI.
Add a comment