This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java in General and the fly likes  java.rmi.NotBoundException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark " java.rmi.NotBoundException" Watch " java.rmi.NotBoundException" New topic


H Padia

Joined: Nov 18, 2009
Posts: 8

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$ Source)
at 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$ Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$ Source)
at Source)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(
at sun.rmi.transport.StreamRemoteCall.executeCall(
at sun.rmi.server.UnicastRef.invoke(
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at client.Client.main(

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

Your help will be appreciated.

Thank you.

K. Tsang

Joined: Sep 13, 2007
Posts: 2231

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

Joined: Nov 18, 2009
Posts: 8
Hello K!
Thank you for your post. The Server seems to work fine. The following is my code for server.

K. Tsang

Joined: Sep 13, 2007
Posts: 2231

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

Joined: Nov 18, 2009
Posts: 8
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.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: java.rmi.NotBoundException
Similar Threads
RMI binding problems
HFJ - RMI issues.
RMI unmarshling error while registering
RMI server startup exception
keeping http clients up to date