• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problems turning on rmiregistry programmatically

 
Ron Patel
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello,
I am having problems when I turn on the rmiregistry programmatically... using LocateRegistry.CreateRegistry.
My RMI servers bind successfully to the registry. However, when I try to connect to these servers, I get NoSuchObjectException.
What could be the problem?
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you trying to create the registry on your local machine or on another machine? The JavaDocs for the LocateRegistry class says this - "Note that a getRegistry call does not actually make a connection to the remote host. It simply creates a local reference to the remote registry and will succeed even if no registry is running on the remote host. Therefore, a subsequent method invocation to a remote registry returned as a result of this method may fail."
 
Chris Shepherd
Ranch Hand
Posts: 286
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
LocateRegistry.createRegistry() only creates a registry locally (and thats working since you can bind to it). It sounds like you're problem is an inconsistency in your Naming.rebind() vs Naming.lookup(). Can you post both of your calls so that we can compare them?
[ April 29, 2004: Message edited by: Chris Shepherd ]
 
Ron Patel
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is the code I use to rebind:
The InvokerServer class extends UnicastRemoteObject.
try{
String name = "Invoke";
IInvoke invokee = new InvokerServer();
Naming.rebind(name, invokee);
System.out.println("Invoker is Listening");
}catch (Exception e){
throw new RuntimeException(e.getMessage());
}

Here is the code I use for lookup
IInvoke invoker = (IInvoke) Naming.lookup("//" + 128.238.44.237 + "/Invoke");
128.238.44.237 is the IP address of the machine I am trying to connect to (the one that has the server bound to rmiregistry using the code above)
 
Chris Shepherd
Ranch Hand
Posts: 286
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmm seems like your lookup might not work right. It should all be string like this:

If that change doesn't work, you may need to mirror this string in your rebind like this:

now you may need to do some internal checking to see what your IP is if the server isn't run on a machine with static IP, but once you know what it is, you can slap it in as a string in place of this one.
I think the first suggestion may fix your problem. The second one may just confuse the issue if it doesn't work, but give it a shot and switch back if it doesn't.
Chris
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!