Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java.lang.ClassCastException

 
Lee Yi
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 66
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 977
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic