I have searched and asked many places. I know it's an offtopic here, but I am sure there are so many experts here that may not mind, and shed some light to me.
The following code would stop working after around 100 hits. If I do not create the inital context each time, then it works fine. But I need this to test some EJB clients.
I run under Windows XP, Sun AppServer 8, J2EE 1.4. Thank you very much for your consideration.
*import javax.naming.Context; import javax.naming.InitialContext; import javax.rmi.PortableRemoteObject; import java.util.*;
public class TestClient {
public TestClient() {
}
public static void main(String[] args) {
int i;
for(i = 0; i < 1000; i++){
System.out.println("i: " + i);
doit();
}
}
private static void doit(){
InitialContext initial = null;
String url = "iiop://localhost:3700";
String ejbService = "HelloWorld";
try{
System.gc();
Properties env = new Properties();
env.put("java.naming.factory.initial", "com.sun.jndi.cosnaming.CNCtxFactory");
env.put(Context.PROVIDER_URL, url);
initial = new InitialContext(env);
Object objref = initial.lookup(ejbService);
}catch (Exception ex) {
System.err.println("Caught an unexpected exception!");
ex.printStackTrace();
}finally{
if(initial != null){
try{
initial.close();
System.out.println("I am here");
initial = null;
}catch(Exception e){
e.printStackTrace();
}
}
}
}
}
*
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
