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 ]
posted 17 years ago
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 ]
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
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.