• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

RMI Help

 
Sham Delaney
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am starting to look into RMI and code my server.
I am new to this and dont know where to start.
Can anyone advise on any decent easy to follow tutorials on RMI that would relate to the type of server we need to build for the Developers Cert.

Also, I keep getting the following exception when trying to a sample server i setup..
java.rmi.server.ExportException: internal error: ObjID already in use

I have looked up all the posts on this site and see where other people had the same issue.
But I cant see how to fix it.

Here is my code;

Registry registry = LocateRegistry.createRegistry(1099);
registry.rebind("Service", new Server());

Please Help.
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12014
220
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sham,

Blatent plug: My book has a chapter devoted to how you can use RMI in a way suitable for this assignment

You can find the Sun RMI tutorial listed in the JavaRanch Reading Materials FAQ.

There is also the jGuru Remote Method Invocation (RMI) short course.

Both those later tutorials discuss RMI in general - it is up to you to apply them to the assignment.

As for the problem you mentioned, do you still get the same error if you use a port other than 1099?

If you dont get the error, then you may already have something listening on port 1099. The questions then would be: are you starting rmiregistry manually, or are you running a J2EE container (SunOne, JBoss, ...)?

If you do get the same error, then I would suspect that you are calling the createRegistry() method in more than one location.

Oh, and not that it is much help at the moment, but you should try and avoid "magic numbers" such as 1099. In that particular case you would probably be better using java.rmi.registry.Registry.REGISTRY_PORT

Regards, Andrew
 
Ian Hamilton
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"netstat -a" from Windows command prompt will list the ports in use
 
Jeroen T Wenting
Ranch Hand
Posts: 1847
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds more like it's generated when trying to register the JNDI name. Are you sure you're not trying to register it twice by mistake?
 
Sham Delaney
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys, Thanks for all your responses.
I have figured out my problem.
I had the code in a constructor..so i was calling it twice.
It was late on Fri evening...and my head wasnt thinking straight,
Thats my excuse and I am sticking to it :-)

Andrew, thanks for the links and the plug...I must have a look for that book of yours.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic