• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

RMI Questions

 
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good evening,
I've searched all the posts regarding RMI in this forum and in the Java Intermediate forum and have not found any that address my issues. Can someone please help me?

I'm using Eclipse SDK 3.1.0 to run a small RMI program (if I can get this to work, I can get back to working on my B&S project). If I don't manually start the RMI server via the command line, I get a ConnectionException even though LocateRegistry.createRegistry(1099) is being invoked inside the server code. I understood that by invoking createRegistry(), it would start the RMI server, is this correct?

If I run the RMI server before running the program I then get a NotBoundException invoking Naming.lookup(). I started the RMI server at the root level (E:\ drive). Do I need to start the RMI server in the directory where the stub and skeleton is or where the class files are? My stub and skeleton are in a folder together, a subdirectory where all my class and java files are.

Perhaps the NotBoundException is due to my lack of understanding of what exactly is the parameter for the Naming.lookup()? It's the directory to what, the skeleton directory?

While searching other RMI posts, one post brought on a question about where the stub and skeleton should reside. If I have a client and server jar file, shouldn't the stub reside in the client jar file and the skeleton in the server jar file?

Thanks for you time and feedback!
 
Ranch Hand
Posts: 516
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Yes LocateRegistry.createRegistry(1099) will start the "rmiregistry.exe".

After that, you need to bind the server object to it:


For this code to work, you must create the stubs for the ServerObject.

Then, on the client's side, you need to lookup for the "SomeText" to get the object:

Here, IP could be another machine's ip, or "localhost" if the client and server are on the same machine. It's where rmiregistry.exe is running, which is always on the same machine as the server (rmiregistry limitation: meaning a server cannot bind itself to a remote rmiregistry.exe).

The client needs to have access to the stubs too.

I believe in current java version, the skeleton is not used (managed behind the scene). not sure.

NotBOundException is thrown (on the client's side) because your server object was not previously bound successfully before you tried to lookup for it.

Hope this helps, any guru please feel free to correct me and help him some more.

Regards,
Alex
[ February 04, 2006: Message edited by: Alex Turcot ]
 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Shannon,

I use the LocateRegistry classes in my code and bypass Naming all together

Server:


Client:


Good luck,

Kevin
[ February 05, 2006: Message edited by: Kevin Conaway ]
 
Shannon Sims
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Alex,
Thank you for your reply! This is a wonderful place where others are so kind to share their knowledge.

I guess a good nights rest is all I needed...the server side code needed to be executed before running the client code...I was only running the client code, which explains why I was getting a ConnectException.

Thanks Alex!
 
Shannon Sims
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Kevin,
Thanks for your reply. Very interesting, most of the posts I've seen use the Naming instead of the Registry? It seems logical to use the Registry, however most of the posts are using the Naming, instead? It is more efficient to use the Registry?
 
Kevin Conaway
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Shannon,

I believe the Naming class is just a shortcut for the LocateRegistry methods. Most people use the Naming methods because most tutorials and guides use them. Naming apparently just parses the url that it accepts and passes it along to LocateRegistry.

I don't believe there is an inherent advantage to using either of these. For code consistency however, if you are using LocateRegistry, you should stick with that.

Kevin
 
Shannon Sims
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Kevin,
Thanks for the explanation. Either way, I guess I'm safe to utilize the Naming or Registry APIs.
 
hangman
Posts: 220
Angular Framework Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Kevin!
You Rock! This info has helped me tremendously!!! Thanks a bunch!

--Bob (the RMI wanna-be)
 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Even better it seems to me

using registry.rebind(...) instead of registry.bind(...)
avoid the AlreadyBoundException

Regards
Y
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic