aspose file tools*
The moose likes Distributed Java and the fly likes java.lang.ClassCastException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "java.lang.ClassCastException " Watch "java.lang.ClassCastException " New topic
Author

java.lang.ClassCastException

Lee Yi
Greenhorn

Joined: Feb 22, 2002
Posts: 3
Hi,
I am applying package concept my Java RMI programs.
I can compile my programs with no errors.
But, when i run my program, I get an error which sound the following:
java.lang.ClassCastException: ServerImpl_Stub
The package has included with the interface class and the .stub file.
This problem didn't occur when I didn't implement package to my programs.
Does anyone know what is wrong?
How do I solve this problem?
Please help me.
Thank you very much.
[ February 22, 2002: Message edited by: Lee Yi ]
[ February 22, 2002: Message edited by: Lee Yi ]
Lee Yi
Greenhorn

Joined: Feb 22, 2002
Posts: 3
I've solve the problem. It is because of the packaging that I applied to my program that causes the problem.
Thank you.
[ February 23, 2002: Message edited by: Lee Yi ]
eric mcentee
Ranch Hand

Joined: May 02, 2001
Posts: 66
I was wondering if you might post your solution. I am having the same problem with a sample RMI program.
I have a suncertify.server package that contains a RemoteTextServer interface, and a textBasedServer class that implements the interface.
In my suncertify.client package, I have the same RemoteTextServer interface, and a textClient.
It appears that my server binds with the RMI registry properly, but when I try to look it up from the client, it throws the exception. To look it up in the client, I create a RemoteTextServer object, and then cast the result of the Naming lookup to that, as in:
RemoteTextServer remoteTextServer = (RemoteTextServer)Naming.lookup(url);
In addition, I have tried to follow the advice I've found on some of the other posts, and copy the stub to my client directory, but no success.
Were you able to solve the problem, or do you just have the client and server in the same package?
Thank you for your insight,
Eric
Marcos Maia
Ranch Hand

Joined: Jan 06, 2001
Posts: 977
hi,
you may find the answer for this problem at:
http://java.sun.com/j2se/1.4/docs/guide/rmi/faq.html
regards.
Lee Yi
Greenhorn

Joined: Feb 22, 2002
Posts: 3
Hi,
Ok, it seems that what you did same like me.
I have my server and client programs in a different package.
I solved my problem my simply renaming those packages to the same name.
It means that the Interface class, implementation class and the client class has the same package name.
Hope it helps.
 
 
subject: java.lang.ClassCastException