coki90
01-10-2011, 17:31
Ragazzi ho un problema con RMI.
Ho creato l'interfaccia remota ControllerInterface:
import java.rmi.*;
public interface ControllerInterface extends Remote{
public void boot() throws RemoteException;
public boolean aggiungiAccount(Account account) throws RemoteException;
public boolean aggiungiTemplate(Template template) throws RemoteException;
public boolean areTemplate() throws RemoteException;
public Template trovaTp(String nome) throws RemoteException;
public boolean creaDocumento (String nome, String nomeTp, String proprietario) throws RemoteException;
public boolean invitaUtente(String nomeProprietario,String nomeDocumento, String invitato) throws RemoteException;
public Documento ricercaDocumento(String nome) throws RemoteException;
public Account ricercaUtente(String username) throws RemoteException;
public Account ricercaAmministratore(String username) throws RemoteException;
public boolean login(String nome, String psw) throws RemoteException;
public boolean bloccaSezione(String user, String sez, String doc) throws RemoteException;
public Sezione salvaSezione(String user, String sez, String doc) throws RemoteException;
}
che come vedete fa un po' di cose.
poi ho implementato l'interfaccia con un oggetto Controller che non vi sto a incollare perchè molto lungo.
Poi ho ovviamente creato il server con la seguente funzione:
public static void main(String args[])throws Exception{
Controller controller=new Controller();
Naming.rebind("ctrl",controller);
}
il problema ce l'ho nel client:
import java.rmi.*;
public class Client{
public static void main(String args[]) throws Exception{
Controller c= (Controller) Naming.lookup("ctrl");
}
}
che mi da il seguente errore in esecuzione:
Exception in thread "main" java.lang.ClassCastException: Controller_Stub cannot be cast to Controller
at Client.main(Client.java:5)
cosa sbaglio?
Ho creato l'interfaccia remota ControllerInterface:
import java.rmi.*;
public interface ControllerInterface extends Remote{
public void boot() throws RemoteException;
public boolean aggiungiAccount(Account account) throws RemoteException;
public boolean aggiungiTemplate(Template template) throws RemoteException;
public boolean areTemplate() throws RemoteException;
public Template trovaTp(String nome) throws RemoteException;
public boolean creaDocumento (String nome, String nomeTp, String proprietario) throws RemoteException;
public boolean invitaUtente(String nomeProprietario,String nomeDocumento, String invitato) throws RemoteException;
public Documento ricercaDocumento(String nome) throws RemoteException;
public Account ricercaUtente(String username) throws RemoteException;
public Account ricercaAmministratore(String username) throws RemoteException;
public boolean login(String nome, String psw) throws RemoteException;
public boolean bloccaSezione(String user, String sez, String doc) throws RemoteException;
public Sezione salvaSezione(String user, String sez, String doc) throws RemoteException;
}
che come vedete fa un po' di cose.
poi ho implementato l'interfaccia con un oggetto Controller che non vi sto a incollare perchè molto lungo.
Poi ho ovviamente creato il server con la seguente funzione:
public static void main(String args[])throws Exception{
Controller controller=new Controller();
Naming.rebind("ctrl",controller);
}
il problema ce l'ho nel client:
import java.rmi.*;
public class Client{
public static void main(String args[]) throws Exception{
Controller c= (Controller) Naming.lookup("ctrl");
}
}
che mi da il seguente errore in esecuzione:
Exception in thread "main" java.lang.ClassCastException: Controller_Stub cannot be cast to Controller
at Client.main(Client.java:5)
cosa sbaglio?