• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Out of 2 RMI registries on the same host, only one can be referenced remotely

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have 2 processes (let’s name them A and B) in different JVMs, but on the same host. Each of these processes creates an RMI registry (let's call them RegistryA and RegistryB) using LocateRegistry.createRegistry( int port ). RegistryA listens on the default 1099 port, and RegistryB listens on a different port.

When I try to get a reference to RegistryB from a remote host using LocateRegistry.getRegistry( String host, int port ) , I always get a reference to RegistryA instead, regardless of the port number I make RegistryB listen on. When I try to get a reference to RegistryB from the same host where it is located, I have to specify as the first argument either the fully qualified domain name of the host or null. If I put the word “localhost” as the first argument, I again get a reference to RegistryA regardless of what I specify as the second argument.

After a few hours of googling, I found only an advice to use just one RMI registry. But I would like to avoid it to keep process A and process B more isolated from each other.

What could you suggest?

Thank you in advance.


 
Bill Jurgen
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The Windows Firewall service is stopped on both the machines, and there is no other firewall between them. Each of the machines has the IP address and name of the other in its Windows hosts file.
 
Bartender
Posts: 1638
IntelliJ IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bill Jurgen wrote: I have to specify as the first argument either the fully qualified domain name of the host or null. If I put the word “localhost” as the first argument, I again get a reference to RegistryA regardless of what I specify as the second argument.



If you are calling getRegistry from a remote host, why would you use "localhost"?
localhost is a loopback interface for the same machine.

If you do not specify a host i.e. pass null, then also it takes the host as "locahost", so technically specifying localhost OR null should have the same effect, unless you have groovy host name settings.

You can have as many number of RMIRegistries on a single box as you want as long as they use different ports.
 
Bill Jurgen
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Excuse me for ambiguity. When I noticed the problem with calling getRegistry(String, int) from a remote host, I decided to call it from the same host where the registry is and use "localhost" as the first argument. I did it just for testing purposes.

I agree that null or "localhost" should yield the same results, and it puzzles me why they don't.
 
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Most of the time, it's cleaner just to run one master registry on one port (1099 for example) and let the various services register themselves with it. That means that the registry server should be running stand-alone (or as part of an independent service such as a webapp container), and not as a dependent component of an application. Two servers are more for things like where one is for testing and one is for production or you're a service bureau and each server is for a separate client.

If you absolutely must run 2 servers and there are no distinctions such as the above, you might consider proxying them with a third server so that external requesters see them as a single server. Offhand, I don't know of an app that does that, unless maybe the Apache directory server can. But there probably are some.

"localhost" is a very problematic name to use in Java due to forward/reverse lookup issues. Usually you get happier results if you supply the server's actual name, even though that's less portable.
 
When it is used for evil, then watch out! When it is used for good, then things are much nicer. Like this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic