jQuery in Action, 2nd edition*
The moose likes Distributed Java and the fly likes ClassCastException on client.main Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "ClassCastException on client.main" Watch "ClassCastException on client.main" New topic
Author

ClassCastException on client.main

W LIU
Greenhorn

Joined: Feb 22, 2004
Posts: 1
Hello, I am new to RMI can following java.sun.com's tutorial, I develop
the following program , however I keep getting a ClassCastException
when I try to cast the remote ojbect into it's interface . I've been
stuck 2 days and doesn't have a clue yet!
//a remote interface:
public interface MyInterface extends Remote{
...
}
//its implement on server
package server;
public MyImpl extends UnicastRemoteObject implements MyInterface{
...
}
ok , now on the client side,NOTE: different package:
//client code
package client
class Client {
...
String name = "...";
MyInterface remote = (MyInterface)Naming(name); //ClassCastException here
....
}
after all codes are done, I have the rmiregistry started ok,
the server started ok
Now when I try to start running my client, it gave me a ClassCastException on main.
when I try println(Naming(name)), it does return the remote object.
I kind of feel that this problem is somehow related to the path setting . I don't know how and why...
please any help would be greatly appreciated!
Thank you
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: ClassCastException on client.main