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.
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 ..........!!!!";
}
> I have the following function in a stateful ejb. When I call this function
> will display
[quoted text clipped - 3 lines]
> 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\
[quoted text clipped - 13 lines]
> return "Say Hello ..........!!!!";
> }
John Ersatznom - 21 Dec 2006 08:52 GMT
>>I have the following function in a stateful ejb. When I call this function
>>will display
[quoted text clipped - 16 lines]
>
> Bingo... infinate loop.
Wait 2147483647 more iterations or so, actually, and it will actually
stop. ;)
wesley.hall@gmail.com - 21 Dec 2006 09:55 GMT
> > Bingo... infinate loop.
>
> Wait 2147483647 more iterations or so, actually, and it will actually
> stop. ;)
True, true. Not infinate I guess. Still you can fix it by changing the
loop counter to long. Even then it wouldn't be infinate, but by the
time it overflowed you would be dead and it would be someone else's
problem :o)
M D - 21 Dec 2006 15:55 GMT
>> > Bingo... infinate loop.
>>
[quoted text clipped - 5 lines]
> time it overflowed you would be dead and it would be someone else's
> problem :o)
I just made this program to make dead lock on purpose.
So there is no way to stop this process until i stop the server?
> I have the following function in a stateful ejb. When I call this function
> will display
[quoted text clipped - 4 lines]
> the server? Currently it keeps displaying the hello line without stopping.
> ....
You do not have any ideas what an EJB is.
Alfred