Jeg gør følgende: 1) Starter rmiregistry: start rmiregistry 2001 2) Start Server: C:\eclipse-SDK-3.2-win32\workspace\RMISamples\src>tree /f /a Mappetræ for diskenheden IBM_PRELOAD Diskenhedens serienummer er 348B-FB89 C:. \---example \---hello Client.java Hello.java Server.java C:\eclipse-SDK-3.2-win32\workspace\RMISamples\src>java -classpath example/hello example.hello.Server Exception in thread "main" java.lang.NoClassDefFoundError: example/hello/Server C:\eclipse-SDK-3.2-win32\workspace\RMISamples\src>java -classpath . example.hell o.Server Exception in thread "main" java.lang.NoClassDefFoundError: example/hello/Server C:\eclipse-SDK-3.2-win32\workspace\RMISamples\src> Source code herunder (output med stack trace findes længere nede) =================================================================== Hello.java: package example.hello; import java.rmi.Remote; import java.rmi.RemoteException; public interface Hello extends Remote { String sayHello() throws RemoteException; } Server.java: package example.hello; import java.rmi.registry.Registry; import java.rmi.registry.LocateRegistry; import java.rmi.RemoteException; import java.rmi.server.UnicastRemoteObject; public class Server implements Hello { public Server() { } public String sayHello() { return "Hello, world!"; } public static void main(String args[]) { try { /* * The main method of the server needs to create the remote object that * provides the service. Additionally, the remote object must be * exported to the Java RMI runtime so that it may receive incoming * remote calls. This can be done as follows: */ Server obj = new Server(); int port = 2002; Hello stub = (Hello) UnicastRemoteObject.exportObject(obj, port); // Bind the remote object's stub in the registry Registry registry = LocateRegistry.getRegistry(2001); registry.bind("Hello", stub); System.err.println("Server ready"); } catch (Exception e) { System.err.println("Server exception: " + e.toString()); e.printStackTrace(); } } } Client.java: package example.hello; import java.rmi.registry.LocateRegistry; import java.rmi.registry.Registry; public class Client { private Client() { } public static void main(String[] args) { int port = 2001; String host = (args.length < 1) ? null : args[0]; try { Registry registry = LocateRegistry.getRegistry(host, port); Hello stub = (Hello) registry.lookup("Hello"); String response = stub.sayHello(); System.out.println("response: " + response); } catch (Exception e) { System.err.println("Client exception: " + e.toString()); e.printStackTrace(); } } } ---------------- stack traces -------- Server exception: java.rmi.ServerException: RemoteException occurred in server thread; nested exception is: java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is: java.lang.ClassNotFoundException: example.hello.Hello java.rmi.ServerException: RemoteException occurred in server thread; nested exception is: java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is: java.lang.ClassNotFoundException: example.hello.Hello at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:385) at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:240) at sun.rmi.transport.Transport$1.run(Transport.java:153) at java.security.AccessController.doPrivileged(Native Method) at sun.rmi.transport.Transport.serviceCall(Transport.java:149) at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701) at java.lang.Thread.run(Thread.java:595) at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Unknown Source) at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source) at sun.rmi.server.UnicastRef.invoke(Unknown Source) at sun.rmi.registry.RegistryImpl_Stub.bind(Unknown Source) at example.hello.Server.main(Server.java:32) Caused by: java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is: java.lang.ClassNotFoundException: example.hello.Hello at sun.rmi.registry.RegistryImpl_Skel.dispatch(Unknown Source) at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:375) at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:240) at sun.rmi.transport.Transport$1.run(Transport.java:153) at java.security.AccessController.doPrivileged(Native Method) at sun.rmi.transport.Transport.serviceCall(Transport.java:149) at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701) at java.lang.Thread.run(Thread.java:595) Caused by: java.lang.ClassNotFoundException: example.hello.Hello at java.net.URLClassLoader$1.run(URLClassLoader.java:200) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at java.lang.ClassLoader.loadClass(ClassLoader.java:251) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:242) at sun.rmi.server.LoaderHandler.loadProxyInterfaces(LoaderHandler.java:707) at sun.rmi.server.LoaderHandler.loadProxyClass(LoaderHandler.java:651) at sun.rmi.server.LoaderHandler.loadProxyClass(LoaderHandler.java:588) at java.rmi.server.RMIClassLoader$2.loadProxyClass(RMIClassLoader.java:628) at java.rmi.server.RMIClassLoader.loadProxyClass(RMIClassLoader.java:294) at sun.rmi.server.MarshalInputStream.resolveProxyClass(MarshalInputStream.java:238) at java.io.ObjectInputStream.readProxyDesc(ObjectInputStream.java:1494) at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1457) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1693) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299) at java.io.ObjectInputStream.readObject(ObjectInputStream.java:339) ... 9 more