Hallo,
ich habe lange im google gesucht aber nix gefunden ich kriege diese exception
Exception in thread "main" java.lang.ClassCastException: $Proxy0 cannot be cast to mypackage.VoteServer
at mypackage.Client.main(Client.java:11)
Danke im Voraus
ich habe lange im google gesucht aber nix gefunden ich kriege diese exception
Exception in thread "main" java.lang.ClassCastException: $Proxy0 cannot be cast to mypackage.VoteServer
at mypackage.Client.main(Client.java:11)
Code:
public interface VoteServer {
public void vote(Integer party);
public List<Integer> currentStandings();
}
public class VoteServerImp extends UnicastRemoteObject implements VoteServer {
public List<Integer> ServerList = new ArrayList<Integer>(9);
public VoteServerImp() throws java.rmi.RemoteException
{
}
public void vote(Integer party){
int i = ServerList.get(party);
i++;
ServerList.set(party, i);
}
public List<Integer> currentStandings(){
return ServerList;
}
public static void main(String args[])
{
try
{
VoteServer server1;
server1 = new VoteServerImp();
java.rmi.Naming.rebind("server1",(Remote) server1);
}
catch(Exception ex){}
}
public class Client {
public static void main(String args[]) throws Exception {
VoteServer serv = (VoteServer)Naming.lookup("rmi://localhost/server1");
serv.vote(2);
System.out.println("2nd voted " + serv.currentStandings().get(2));
System.out.println("1se not voted "+ serv.currentStandings().get(1));
}
}
Danke im Voraus