RMI on client side generating exception when getting a reference to the RMI server
Posted
by Noona
on Stack Overflow
See other posts from Stack Overflow
or by Noona
Published on 2010-06-07T15:26:17Z
Indexed on
2010/06/07
16:52 UTC
Read the original article
Hit count: 527
When I try to run an RMI client after running the RMI server I get the following exception:
EncodeInterface exception: java.lang.ClassCastException: $Proxy30 cannot be cast to hw2.chat.backend.main.EncodeInterface
java.lang.ClassCastException: $Proxy30 cannot be cast to hw2.chat.backend.main.EncodeInterface
at hw2.chat.backend.main.EncodingRmiClient.initialiseRMIClient(EncodingRmiClient.java:26)
And the relevant code in the RMI client is:
EncodeInterface encodeInterface;
Registry registry = LocateRegistry.getRegistry(host, portNumber);
encodeInterface = (EncodeInterface)registry.lookup("RmiEncodingServer"); //line 26
And in the RMI server:
try
{
EncodeInterface encodeInterface = new EncoderImpl();
Registry registry = LocateRegistry.getRegistry();
registry.rebind("RmiEncodingServer", encodeInterface);
System.out.println("RmiEncodingServer is running...");
}
EncodeInterface
is the interface that extends Remote
and that is present in the client side too.
Host is "127.0.0.1" and portNumber is 1099 (I am assuming it should be the default value which is 1099 since I didn't specify it when I ran my RmiEncodingServer
).
If I don’t run the RMI server I get the same exception, any ideas as to why this is happening?
thanks
© Stack Overflow or respective owner