• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java.rmi.NotBoundException

 
H Padia
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am trying to create an RMI. I am getting " java.rmi.NotBoundException " error. I am sure that the firewall on server side and the client side are turned off. Also, the /etc/hosts file contain the correct IP address of the server machine.

The following is the code at the client end:




The following is the stact trace:

Client exception: java.rmi.NotBoundException: rmi://ServerMc:1099/Services
java.rmi.NotBoundException: rmi://ServerMc:1099/Services
at sun.rmi.registry.RegistryImpl.lookup(Unknown Source)
at sun.rmi.registry.RegistryImpl_Skel.dispatch(Unknown Source)
at sun.rmi.server.UnicastServerRef.oldDispatch(Unknown Source)
at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
at sun.rmi.transport.Transport$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:273)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:251)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:377)
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at client.Client.main(Client.java:29)


I tried going through a few forums, but not of much luck.

Your help will be appreciated.

Thank you.

-H
 
K. Tsang
Bartender
Posts: 3403
13
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

What is your server code look like? This exception you are having most likely caused by server not set up properly.
 
H Padia
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello K!
Thank you for your post. The Server seems to work fine. The following is my code for server.

 
K. Tsang
Bartender
Posts: 3403
13
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah I see the problem. Your name of the server is wrong. You use "Services" in the server class (line 18). But in your client you are binding to "ServerMc" (line 7). Both of these must be the same.

Now some nitpick. Since you are using RMI, then your Server class should extend UnicastRemoteObject and it should also have a default constructor throwing RemoteException. How about the Services interface? Does it extend Remote interface?

The 2nd nitpick is your registry in your Server class. If you created your registry on line 11 then you really don't need line 17. Or you can simply create the registry on line 17 and remove line 11. Then for line 18, I recommend using rebind rather than bind. Don't ask me why.

If you are in doubt on how to set up the files ... please refer to the RMI Java tutorial
 
H Padia
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello K!

It works now. I made the following changes in the Client class:


In the Server class Line 18 "Services" is a name associate with the remote reference, 'stub' in my case. While the "ServerMc" in line 7 of Client class is the name of the Server Machine in my /etc/hosts.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic