Ciao a tutti,
Ho un problema con RMI.
Ho provato a far funzionare un programma ma non riesco, saltan fuori eccezioni. Il programma è il seguente:
File ProvaRMIServer.java
File ProvaRMIServerImpl.javacodice:package RMITest1; import java.rmi.*; public interface ProvaRMIServer extends Remote { public void print(String s) throws RemoteException; public int getCounter() throws RemoteException; }
File ProvaRMIClient.javacodice:package RMITest1; import java.rmi.*; import java.rmi.server.UnicastRemoteObject; public class ProvaRMIServerImpl extends UnicastRemoteObject implements ProvaRMIServer { int counter; public ProvaRMIServerImpl() throws RemoteException {} public void print(String s) throws RemoteException { System.out.println(s); } public int getCounter() throws RemoteException { return counter++; } public static void main(String[] args) { try { // System.setSecurityManager(new RMISecurityManager()); ProvaRMIServerImpl server = new ProvaRMIServerImpl(); Naming.rebind("ProvaRMIServer", server); System.out.println("Server bound"); } catch (Exception e) { e.printStackTrace(); } } }
Ho compilato i file con javac e ottenuto i class.codice:package RMITest1; import java.rmi.*; public class ProvaRMIClient { public static void main(String[] args) { try { System.setSecurityManager(new RMISecurityManager()); System.out.println("Looking up server..."); ProvaRMIServer server = (ProvaRMIServer) Naming.lookup("rmi://localhost/ProvaRMIServer"); System.out.println("Server bound..."); server.print("prima prova"); System.out.println(server.getCounter()); } catch (Exception e) { e.printStackTrace(); } } }
Ho creato lo stub di ProvaRMIServerImpl con rmic.
Ho settato come CLASSPATH=".";"C:\RMITest1\" ma nulla. La struttura della directory è: C:\RMITest1\RMITest1\files vari...
Ho lanciato rmiregistry e lanciato il server ProvaRMIServerImpl, ma ottengo un sacco di eccezioni, tra le quali:
Dove sbaglio?codice:java.rmi.ServerException: RemoteException occurred in server thread; nested exception is: java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is: java.lang.ClassNotFoundException: RMITest1.ProvaRMIServer

Rispondi quotando