I am getting this error:
java.lang.ClassCastException: $Proxy0 cannot be cast to rmi.engine.Call
at Main.main(Main.java:39)
My Abstract
and Call
class both extend Remote
.
Call:
public class Call extends UnicastRemoteObject implements rmi.engine.Abstract {
public Call() throws Exception {
super(Store.PORT, new RClient(), new RServer());
}
public String getHello() {
System.out.println("CONN");
return "HEY";
}
}
Abstract:
public interface Abstract extends Remote {
String getHello() throws RemoteException;
}
This is my main:
public static void main(String[] args) {
if (args.length == 0) {
try {
System.out.println("We are slave ");
InetAddress ip = InetAddress.getLocalHost();
Registry rr = LocateRegistry.
getRegistry(ip.getHostAddress(), Store.PORT, new RClient());
Object ss = rr.lookup("FILLER");
System.out.println(ss.getClass().getCanonicalName());
System.out.println(((Call)ss).getHello());
} catch (Exception e) {
e.printStackTrace();
}
} else {
if (args[0].equals("master")) {
// Start Master
try {
RMIServer.start();
} catch (Exception e) {
e.printStackTrace();
}
}
Netbeans says the problem is on line 39 which is
System.out.println(((Call)ss).getHello());
The output looks like this:
Run:
We are slave
Connecting 10.0.0.212:5225
$Proxy0
java.lang.ClassCastException: $Proxy0 cannot be cast to rmi.engine.Call
at Main.main(Main.java:39)
BUILD SUCCESSFUL (total time: 1 second)
I am running a master in cmd listening on port 5225.