Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / December 2006

Tip: Looking for answers? Try searching our database.

avoid deadlock with stateful EJB

Thread view: 
sk - 21 Dec 2006 02:24 GMT
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 ..........!!!!";
   }
Wesley Hall - 21 Dec 2006 07:59 GMT
> 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?
Alfred - 22 Dec 2006 16:35 GMT
> 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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.