File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes RMI Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "RMI Problem" Watch "RMI Problem" New topic

RMI Problem

Dave Teare
Ranch Hand

Joined: Oct 09, 2002
Posts: 80
Hi All,
I had my assignment working with RMI, when I decided I did not like the class name of my remote server and refactored it to a new name.
Now my client can no longer bind to the RMI server! I get this exception:

I register the server in RMI as follows:

And then I access the server from the client as such:

FBNDataBaseRemoteImpl is defined as follows:

Am I missing something, or perhaps mistyped something? Like I said, everything was fine before I changed the class name.
Sai Prasad
Ranch Hand

Joined: Feb 25, 2002
Posts: 560
Can you try to create the _Stubs again and give it a try?
Dave Teare
Ranch Hand

Joined: Oct 09, 2002
Posts: 80
I have tried recompiling all the code, including the stub. Also, I even rebooted the machine on the off chance some rouge process was hanging around. But alas, it still fails with a class cast exception.
I stepped through the code with the debugger, and the Naming.lookup does indeed return a valid FBNDataBaseRemoteImpl_Stub object. The problem occurs when I cast it to a FBNDataBaseRemoteImpl object.
The FBNDataBaseRemoteImpl object extends UnicastRemoteObject and implements Remote. Is there something wrong with my FBNDataBaseRemoteImpl declaration?
Dave Teare
Ranch Hand

Joined: Oct 09, 2002
Posts: 80
Fixed it!!!
It was a JDK/JRE version problem. I had an older JRE sitting in the system path, and somehow my vm must have been loading some older files.
I have no idea how my RMI implementation could have ever worked, I did not change the PATH or CLASSPATH. Perhaps when I modified the code, I inadventantly caused a diffent code path to be executed within the underlying RMI impl.
Anyway, there goes 4 hours of my life! On to the next bug!
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17249

Nah, it didn't help for me. I have Oracle's JRE in my path, and I removed it, even at the expense of not being able to run some Oracle tools. And the deleted all the class files and recompiled and re-rmic'd but still no avail.

Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Dave Teare
Ranch Hand

Joined: Oct 09, 2002
Posts: 80
What exception are you getting? Is it a class cast? Post some snipits of code and I will compare it to mine as well as trying it on my machine.
I found the RMI incredibly easy to set up and get working THE FIRST TIME. Once it broke, it is very hard to debug!
If you want to, mail me the relevant code and I will test it on my machine.
Good Luck!
I agree. Here's the link:
subject: RMI Problem
Similar Threads
Stupid deployment question - Again!
Habibi book: How many instances of remote object and Data object exist ?
Using Java ManagedBean and RMI to access methods on a server.
RMI Server and clientID
B&S 2.2.2 - Network Layer Query