The moose likes Developer Certification (SCJD/OCMJD) and the fly likes RMI Port Number Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Professional Certification » Developer Certification (SCJD/OCMJD)
Reply Bookmark "RMI Port Number" Watch "RMI Port Number" New topic
Author

RMI Port Number

Matt DeLacey
Ranch Hand

Joined: Oct 12, 2000
Posts: 318
Hello...my App works great in remote mode, but only if I run the server on the default registry port (1099) anything else and I get a java.rmi.ConnectIOException: error creating connection to <machinename>. It works fine on port 1099 though. Is it possible that this is happening because of a firewall here at work? In light of this is it reasonable to hardcode 1099 in as the port?
With Respect,
Matt DeLacey
Paul Anilprem
Enthuware Software Support
Ranch Hand

Joined: Sep 23, 2000
Posts: 2547
I really don't think there is an issue with firewall. Firewall comes into picture when you are running the client and the server on diff. m/cs and that too on different intranets eg. server at your office and client at your home pc. That's when the whole traffic passes through the firewall and in most of the cases, the firewall does not allow connections from outside to inside.
But you said, every thing is working fine on 1099. And you have not given when (while starting the server or starting the client) are you getting the exception.
Are you giving the right port no. to your server program to bind the object to the registry? Are you giving the same port no. to your client? Most prob. that is the issue.

HTH,
Paul. http://www.enthuware.com/jdevplus
You guide to SCJD exam!

------------------
Get Certified, Guaranteed!
(Now Revised for the new Pattern)
www.enthuware.com/jqplus

Try out the world's only WebCompiler!
www.jdiscuss.com


Enthuware - Best Mock Exams and Questions for Oracle/Sun Java Certifications
Quality Guaranteed - Pass or Full Refund!
Matt DeLacey
Ranch Hand

Joined: Oct 12, 2000
Posts: 318
Thanks Paul:
The problems occurs when I am starting up my Server (that's when I get the exception). I do give the correct address and port number on the client and the server but it's kind of moot what port number I'm giving on the client, because the server fails before it successfully starts up. But, yes, the only time I have problems is when I run on a port other than 1099 (the default) and then I get that exception when launching the server.
Matt
Paul Anilprem
Enthuware Software Support
Ranch Hand

Joined: Sep 23, 2000
Posts: 2547
hmmm.. can you tell me what is your command line for starting the rmiregistry and you server?
-Paul.

------------------
Get Certified, Guaranteed!
(Now Revised for the new Pattern)
www.enthuware.com/jqplus

Your guide to SCJD exam!
www.enthuware.com/jdevplus
Try out the world's only WebCompiler!
www.jdiscuss.com
Matt DeLacey
Ranch Hand

Joined: Oct 12, 2000
Posts: 318
I just say java suncertify.server.DataServer
The port is hardcoded in for now until I get this issue
worked out.
I use LocateRegistry.createRegistry(port_no)
Then I create an instance of ServerImpl and
then pass that to the Naming.rebind method.
It's very straightforward, and as I say it works
100% when using port 1099. I've done exhaustive
testing and tested on separate machines and
whatnot. It's strange....

With Respect,
Matt DeLacey
Paul Anilprem
Enthuware Software Support
Ranch Hand

Joined: Sep 23, 2000
Posts: 2547
I just made quick changes to my implementation and found everything working just fine. This is what i did:
1. started the regis. on diff. port: (on a seperate dos window)
c:>rmiregistry 1098
2. Started the server (I pass the port no of the registry as an argument)
In the main method of the server, all i do is:
Naming.rebind(name, thedb);
Here, name is: "rmi://127.0.0.1:"+args[1]+"/RemoteFlyByNightDB" //uses args
and "thedb" is the object that i am binding.
And everything works just fine.
Now a couple of points you might want to check...
.Why are you using LocateRegistry.createRegistry(port_no)? Just start the regis. from dos prompt by typing "rmiregistry"!!
.What is the "name" (should fully qualified eg. "rmi://127.0.0.1:1098/RemoteFlyByNightDB" that you are passing to Naming.rebind()?
Everything surely works for 1099 as that is the default port but when you change it you need to make sure that both the processes ie. the regis. and your server (actualy the "name") have the same port no. Just double check these two things and I'm sure it will work.
-Paul.


------------------
Get Certified, Guaranteed!
(Now Revised for the new Pattern)
www.enthuware.com/jqplus

Your guide to SCJD exam!
www.enthuware.com/jdevplus
Try out the world's only WebCompiler!
www.jdiscuss.com
Matt DeLacey
Ranch Hand

Joined: Oct 12, 2000
Posts: 318
Paul,
1000 thanks. The string that you call name I was just passing
it the name. When I saw what you had done I passed it the complete path i.e. "rmi://localhost ort_no/objname" instead
of just name. That did the trick. Thanks for being patient with me and seeing me through this one.
With Respect,
Matt DeLacey
Dilip kumar
Ranch Hand

Joined: Oct 16, 2000
Posts: 360
Matt,
How did you fix this problem.
I'm getting following error when I execute
Naming.rebind("rmi://RPC4553:1098/Data", new Data("db.db"));
java.security.AccessControlException
Did you modify policy file ?
Thanks

[This message has been edited by Dilipkumar Kalyankar (edited April 24, 2001).]
Matt DeLacey
Ranch Hand

Joined: Oct 12, 2000
Posts: 318
you might try rmi://localhost:1098/data
(localhost instead of the other).
Yes, I have a policy file where I give all
permissions, but it works without it too. Maybe it's
because my default persmissions file has has the right
permissions, I don't know.
With Respect,
Matt
Andrew Spruce
Greenhorn

Joined: Feb 27, 2001
Posts: 21
I think these methods all work ok if no security manager is used.
However if you define a security manager, either explicitly in your code or through the -Djava.security.manager option then java starts to get picky about permissions.
I have chosen not to use the AllPermissions option as this seems to be the same as not bothering with the security manager at all.
I think the policy file is useful if the user would like to review the permissions granted to the application and make the decision whether or not the code could be malicious.
By allowing all permissions it could delete his home directory for instance.
But if you are explicit in the policy file, by say defining that the app can only create or delete files in the current directory and all subdirectorires. Then the user has a bit more confidence.
Anyone disagree ?
[This message has been edited by Andrew Spruce (edited April 26, 2001).]
 
 
subject: RMI Port Number
 
Threads others viewed
Exporting Objects on same port as RMI Registry
do i have to supply a port number when start server?
rmi Exception
Client/Server command line options
rmiregistry says port already in use
IntelliJ Java IDE