Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

RMI Problem

 
Mehmet Atlihan
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello guys
I was about to submit the project but during testing phrase I have run into a problem yet I am unable to identify the reason.
What happens is when the "Server" and "Client in network mode" is started
The client "lookup" the remote service and retrieves the reference to it which is priorly binded via server. Everything is fine up to that moment the client can search for rooms and book if he wants to. But when I shut down the server (not unbinding rather closing the server application), the client keeps on performing operations where I expect it to throw a ConnectionException.
What I did to figure out what is wrong was to Log book and search operations and make sure they have the remote servers reference.It turns out they are invoking on the remote objects reference so nothing seems wrong there.
The remote object(server) is extending UnicastRemoteObject so that alone should give him the abilities of throwing generated exceptions. I wonder how client can keep on operating on the remote database, even when the server is not up. I have not tested the application on two different machines yet that is all my tests occured in localhost.
Any ideas/suggestions will be appreciated.
Thank You
Mehmet
 
George Marinkovich
Ranch Hand
Posts: 619
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mehmet,
So you start your server in one window: java -jar runme.jar server
And then you start your network client in another window: java -jar runme.jar
Then you configure the network client to use localhost as the network server
Everything seems to work correctly, searches and bookings.
Then you kill the server (that is, the java -jar runme.jar server application), but the network client continues to work correctly?
You're still able to do searches and bookings?
Then your network client can't be using your server, that much is certain (I think!).
Here are some random ideas:
Are you absolutely sure that your network client is running in network client mode rather than standalone mode. If it's running in standalone mode that would explain the symptoms (although not the logging?!?)
Could you have two applications running in server mode? Don't even know if this is possible. But I guess you could then kill one of the servers, and there would still be a server running somewhere...
Could you be swallowing the exceptions? That would explain why you don't get them, but it wouldn't explain why the application continues to work?!??
Are you sure you're doing all the RMI stuff correctly?
remote object server extends UnicastRemoteObject
you rmic'ed the remote object server class to produce the stub class?
you bind the remote object server to the rmi registry when you start the server?
your network client does a lookup on the RMI registry to obtain the remote object server?
Ok I'm all out of ideas...
 
Mehmet Atlihan
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi George thanks for giving your time
So you start your server in one window: java -jar runme.jar server
And then you start your network client in another window: java -jar runme.jar
Then you configure the network client to use localhost as the network server
Everything seems to work correctly, searches and bookings.
Then you kill the server (that is, the java -jar runme.jar server application), but the network client continues to work correctly?
You're still able to do searches and bookings?

Yes thats exactly what is happening.

Are you absolutely sure that your network client is running in network client mode rather than standalone mode. If it's running in standalone mode that would explain the symptoms (although not the logging?!?)

Yes. I am sure it is running in network mode as I provide logging for
"binding" stuff and according to it ,the client first thing is to lookup for the service and retrieve the reference to it when running in network mode.
For the rest of your questions let me briefly more talk about the design I have may be the problem is hidden somewhere there and I cant realize it.
The application (server )which is responsible for starting the server does not actually extend UnicastRemoteObject because it already extends Observable in order to notify his listeners when an update occurs. I implemented it in that way to stick with MVC pattern.The server handles the requests(read,update,delete,create) by invoking "Data" classs corresponding methods In other words I used Data class as an adapter in server.
Furthermore I have created a singleton RemoteProxy Class which actually extends the UnicastRemoteObject which is capable of doing everything that the server does and implement them via referencing Server class localy. Its methods again implemented as an Adapter. RemoteProxy reference is the reference returned when the client does a lookup. And that is the class name I get during Log.
So what Server class does is to get the singleton RemoteProxy reference
and bind it.
It might be a silly question but as I have run out of ideas could it be because the class who starts the server is not the one who actually is the remote object ? I highly doubt it but anyways..
Thanks
Mehmet
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12014
220
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mehmet,
How long are you waiting to see if you get an exception? From memory, if I deliberately crashed my server and then made a booking, I had to wait around 10 minutes before getting any exceptions.
If you do get the exception eventually then I would probably not worry about it. Perhaps make a note in your design decisions document and/or your user documentation to state that it time out eventually.
Are you spawning new threads on the client side to perform the actual booking? This is nicer from the user's perspective, but can make it harder to propogate the exception back the main client thread - if you are doing this, you may have to double check your logic for getting the exception reported back.

the client keeps on performing operations where I expect it to throw a ConnectionException.

Do you mean that as far as the client is concerned, it appears the bookings / searches are all working correctly?
Regards, Andrew
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic