ClassCastException using Naming.lookup()
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Matt_Senecal
Posted On:   Friday, October 12, 2001 12:00 PM

A client I've written is trying to connect to a server that resides on another machine. The server is an implementation of the interface MyServer, and is called MyServerImpl. During the Naming.lookup() call in the client I'm getting a ClassCastException: java.lang.ClassCastException: MyServerImpl_Stub This is the code in question: MyServer my_server = null; String name = "//121.0.0.42/MyServer"; my_server = (MyServer)Naming.lookup( name ); //exception thrown here I've checked, and there *is* a stub being returned from the lookup call. The server is up and running on the other machine, and was compiled from the same code that the client is referen   More>>

A client I've written is trying to connect to a server that resides on another machine. The server is an implementation of the interface MyServer, and is called MyServerImpl. During the Naming.lookup() call in the client I'm getting a ClassCastException:



java.lang.ClassCastException: MyServerImpl_Stub



This is the code in question:



			
MyServer my_server = null;
String name = "//121.0.0.42/MyServer";
my_server = (MyServer)Naming.lookup( name ); //exception thrown here



I've checked, and there *is* a stub being returned from the lookup call. The server is up and running on the other machine, and was compiled from the same code that the client is referencing. From what I can tell, this should work, but apparently there's a disagreement between the stub being returned and the variable used to hold it. Anyone have any ideas why it's not working?

   <<Less

Here's how I solved it.

Posted By:   Matt_Senecal  
Posted On:   Monday, October 22, 2001 12:35 PM

Here's how I finally solved this. I took the compiled RMI STUB and SKEL files from the server and replaced the corresponding files on the client machine with them. Then I re-ran the client, and the problem vanished!



Interesing, this. Same code, same java version, the only thing that's different is that the server is Solaris 8, and the client is Win 2000.

About | Sitemap | Contact