This discussion is archived
7 Replies Latest reply: Aug 29, 2012 11:28 AM by jtahlborn RSS

Java remote interface - RMI tutorial - error: unmarshalling arguments

957253 Newbie
Currently Being Moderated
Trying to test the rmi tutorial via Netbeans to set up a remote server - client interface.
When running the server the following exception appears:

exception: java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: remotetests.MyRemoteInterface

The rmi registry is running in the background.

It seems the server is unable to publish the remote object??
Below are server, remote interface and client classes

Please help - Thanks!

The server class looks like this:

package remotetests;

import java.rmi.*;
import java.rmi.registry.LocateRegistry;
import java.rmi.server.*;

+public class MyRemoteClass extends UnicastRemoteObject implements MyRemoteInterface, Serializable {+

+public MyRemoteClass() throws RemoteException {+
+//Constructor code+
System.out.println("MyRemote constructor");

+public void myMethod1() throws RemoteException {+
+//Here we put the code we want+
System.out.println("I am in myMethod1()");

+public int myMethod2() throws RemoteException {+
return 5; //Here we put the code we want

+public void anotherMethod() {+
+//If we define another method, this can´t be called in a remote way unless we call it from the remote interface+

+public static void main(String[] args) {+
+try {+
System.out.println("running main");
MyRemoteInterface mir = new MyRemoteClass();
InetAddress address =;
System.out.println("host name : " address.getHostName());+
+// Naming.rebind("//" +"/RMI_Test", mir); //":" ++args[0]+
LocateRegistry.getRegistry().rebind("//", mir);+
+// System.out.println("Server started. Bound RMI test");+
+} catch (Exception e) {+
System.err.println("exception: " e);+

The remote interface class:

package remotetests;
import java.rmi.*;

+public interface MyRemoteInterface extends Remote {+

public void myMethod1() throws RemoteException;

public int myMethod2() throws RemoteException;


The client class:

package remotetests;

+public class MyRMIClient {+

+public void MyRMIClient(String[] args){+

MyRemoteInterface mir = (MyRemoteInterface) java.rmi.Naming.lookup("//"args[0] +":" args[1]"/RMITest");+
+//MyRemoteInterface mir = (MyRemoteInterface) java.rmi.Naming.lookup("//");+
+//We print myMethod1() as much as we get back myMethod2()+
int monitor = mir.myMethod2();
for(int i=1;i<mir.myMethod2();i+){+

+}catch (Exception e){+


  • Correct Answers - 10 points
  • Helpful Answers - 5 points