• 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

RMI Registry help

 
Ranch Hand
Posts: 532
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 72
 
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sean Gildea
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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

 
Andrew Monkhouse
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
reply
    Bookmark Topic Watch Topic
  • New Topic