Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Changing RMI port from 1099

 
ghanshyam sharma
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys
Somehow I can't make my server use any other port then 1099, the default RMI port. Any clues as to what I am doing wrong ???
Thanks.
-Sharma
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you by any chance using LocateRegistry.getRegistry() or LocateRegistry.getRegistry(hostNameString). If yes by default it will use RMI port 1099. Check the
API
HTH
-Amish
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 11944
212
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sharma,
If you are starting the rmiregistry from the command line, then show us the command line. If you are starting it programattically then show us the line of code that starts it.
Likewise, show us the line of code that registers with the registry, and that does the lookup on the registry.
When we see what you are doing, we will be able to make suggestions.
Regards, Andrew
 
ghanshyam sharma
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I use the following code to start the registry.
java.rmi.registry.LocateRegistry.createRegistry(port);
surprisingly if I use any other port except 1099 I get an exception. The message says Connection refused to host <my ip address>. [java.net.ConnectException]
Thanks for your help already.
-sharma
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 11944
212
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sharma,
Are you specifying the port number in your calls to bind()/rebind()/lookup()?
Regards, Andrew
 
Ken Krebs
Ranch Hand
Posts: 451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sharma,
Before your LocateRegistry.getRegistry(port) call, you should create a
registry for your port of interest. The following works for me.

kktec
SCJP1.4, SCWCD
 
Joy DeGrazzio
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ken,
what is the difference between the Naming and Registry classes? I think the original poster had a problem because he was using the Naming class to bind and unbind remote objects. You created a Registry object to do this however, and avoided the same problems. The API really doesn't seem to tell much.
 
Ken Krebs
Ranch Hand
Posts: 451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Joy,
As near as I can tell, the difference is that the port number is embedded as part of a URL when using Naming instead of being used as a method argument to a direct call on the registry. I changed my code to use Naming as shown below. Both techniques work. I really don't see a good reason to prefer the Naming technique over the one I used which seems simpler, more straightforward, and easier to debug. You still have to create the registry using either technique.

kktec
SCJP1.4 & SCWCD
 
Ken Krebs
Ranch Hand
Posts: 451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After thinking about it a little more, I guess a reason to use Naming would be if the registry is created in another process/JVM and our program is adding services to it. There's no need to do that here.
kktec
SCJP1.4 & SCWCD
 
mao lao
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
a question about this, Can I just use command line to start rmiregistry?
like >start rmiregistry 1099
and then start the database server?
[ September 27, 2003: Message edited by: mao lao ]
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 11944
212
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mao,
You can, and this is probably what you would have to do for a real project.
However if you do this, and the RMI Registry is started in a directory other than where you code is, you will have to define the codebase. The new assignments do not allow you to specify the codebase on the command line, so you would have to programattically set the codebase.
Personally I think you will find it much easier to start the RMI Registry from within your program. This also means that the examiner won't have to start the RMI Registry manually.
Regards, Andrew
 
mao lao
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic