• 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

Running RMI registry on ramdon port

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello all,

I am running my RMI registry in linux as

It some times throws an error that port is already bind.
I have also tried the default port for registry i.e. 1099 but some time same error occurs.
I think this might be because when I close my RMI registry some process might allocate the port on which my RMI registry was running and when I retry to run registry it gives me error.
Due to this I need to change the code in my client side where I have used Naming.loookup() method.
Also I have tried regisry.lookup() method but do not get any success.

If there is any method to run registry on random port and send it to client when client wants to connect to the server???
Or suggest me what to do.
Thanks in advance.
 
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
rajshkhr,

Both the client and the server need to know the RMI port they are running on ahead of time. Otherwise, the server wouldn't be able to send a message to the client telling it what port to listen to since the client wouldn't know what port to listen for the message on. Port 1099 shouldn't usually be in use by anything else since it is typically reserved for RMI. If it is also happening with other "random" ports, maybe the registry isn't being shutdown properly. Are you sure the registry is no longer running when you try to restart it? Also, is it possible that you are also trying to create it from your java process using LocateRegistry.createRegistry and also start the rmiregistry process (effectively trying to start the registry twice)?

When you do get the error, you could use netstat to determine what is using that port.

Jeff
 
rajshkhr pandey
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Jeff,

Thanks for your reply.
Actually when ever I want to restart my registry I use to kill process method from the command prompt ensuring that RMI registry is shut down, and then restart registry with the same port number, then some time it throws an exception/error that port is already bind or some time it successfully starts on the same port.

Also some time on port no 1099 same exception is thrown.
 
Jeff Storey
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I wonder if the hard kill is causing the port to stay active and not always shutting down properly. When it happens again, just run netstat to see what's using the port.
reply
    Bookmark Topic Watch Topic
  • New Topic