• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

java.lang.ClassCastException  RSS feed

 
Greenhorn
Posts: 3
  • 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
  • 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 ]
 
Ranch Hand
Posts: 66
  • 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
 
Ranch Hand
Posts: 977
  • 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
  • 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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!