Forums Register Login

RMI Registry help

+Pie Number of slices to send: Send
hi:
I am using RMI registry to register remote objects. In the registery, I have the line:

LocateRegistry.createRegistry(1099);
Naming.rebind(serverName, data);

Sometime it work fine, and sometimes it give me this error:
java.net.BindException: Address already in use: JVM_Bind

can someone explain to me what is going on?
thanks
+Pie Number of slices to send: Send
+Pie Number of slices to send: Send
Hi Hanna,

The reason for your error is rooted in the fact that TCP/IP 'guarantees' delivery of data. As part of this, each connection between sokects on two computers (or one computer with the loopback) must be unique.

Think of it as though a computer is like a telephone exchange with a unique address (its IP address) and up to 65,535 telephone numbers (the total number of ports in a computer). When a server program starts on a computer (or more accurately an IP address), it reserves one of the ports for its exclusive use. This is like somebody reserving exclusive use of one of the telephone numbers in the telephone exchange. For SSH for instance, this is port is 22. The default port for RMI is 1099 if I remember. The combination of an IP address and a port number is known as a socket.

This 'reserving' of a port is known as binding. Once a port has been bound by a service, another program cannot bind itself to this same port. This makes sense as if, say, two ftp servers are trying to listen on the same port - which would answer a connection request from a client?

So what is a connection? It is a socket pair made up of the client IP address and port number along with the server IP address and port number. This must be unique for the reasons I have just explained.

The error message you have is because you are trying to bind a port number which has already been bound by another program. This will be because you have started the RMI server once, binding it to port 1099. You have then attempted to start another instance of the server on the same port. You will not be allowed to do this for the reasons above. You will need to stop the first instance of the server to release/unbind this port first.

Regards,

Jon
[ June 05, 2004: Message edited by: Jon Entwistle ]
+Pie Number of slices to send: Send
I'm getting the same error when i try a port other than 1099, and I checked Netstat to make sure I wasnt using a port already in use

anyone have any ideas?
+Pie Number of slices to send: Send
Hi Sean,

I'm getting the same error when i try a port other than 1099, and I checked Netstat to make sure I wasnt using a port already in use

anyone have any ideas?



The common problem that people come across when their RMI Registry uses a non default port is that they forget to use the non default port when binding their server application.

I would recommend you post your relevant lines of code (like Hanna did), and post the exception you get.

Regards, Andrew
+Pie Number of slices to send: Send
Thanks Andrew!

Here is the code that works when I input 1099 in my port connection box, but that errors out ( exception below ) when I put in a different port number.



Here is the exception I get

+Pie Number of slices to send: Send
Hi Sean,

Here is the code that works when I input 1099 in my port connection box, but that errors out ( exception below ) when I put in a different port number.




The problem here is that the call to Naming.rebind is going to use the standard port of 1099, which doesnt exist if you started a registry on a different port.

The LocateRegistry.createRegistry() method returns the registry just created. So you can then use the rebind() method of that particular registry, which will ensure you are using the correct port.

Regards, Andrew
They weren't very bright, but they were very, very big. Ad contrast:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1578 times.
Similar Threads
VAJ RMI classpath
about rmi protocols
about security manager
Running the RMI registry
URLBirdy: RMI Question
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 02:22:07.