RemoteException in RMI: cant bind my server

Im very sad. Although im not very trained in using rmi this example worked yesterday
with little modifications. its just a very basic rmi program:


/**
* Remote Interface
*/
import java.rmi.Remote;
import java.rmi.RemoteException;

public interface IRemote extends Remote
{
    public void test() throws RemoteException;
}


/**
* Server
*/
import java.rmi.Naming;
import java.rmi.RMISecurityManager;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;

public class HelloServer extends UnicastRemoteObject implements IRemote
{
    public HelloServer() throws RemoteException
    {
        super();
    }

    public void test() throws RemoteException
    {
    	System.out.println("REMOTE CALL");
    }

    public static void main(String args[])
    {
        try
        {
            if (System.getSecurityManager() == null)
            {
                System.setSecurityManager(new RMISecurityManager());
            }

            HelloServer h = new HelloServer();
            Naming.rebind("rmi://localhost/Hello", h);

            System.out.println("[DerServer]registrierte Objekte nach dem Binden");
            
            for (int i = 0; i < Naming.list("rmi://localhost/").length; i++)
            {
                System.out.println("[Server] "+ Naming.list("rmi://localhost/")[i]);
            }

            System.out.println("[Server] ready.");
        } catch (Exception re)
        {
            System.out.println("Exception: " + re);
        }
    }
}

The problem is that i get this exception thrwon by the rebind() method:


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

Im using Eclipse 3.1 and Java 1.5 (so no rmic). Moreover im using as vm Arguments for Eclipse


-Djava.security.policy=grant_all.policy
-classpath .

the rmiregistry is running and working, if i dont implement the remote interface i can call it
using Naming.<…>

Why the **** hell cant it find the IRemote interface ?!

Just make sure that any class that you are trying to use remotely is Searlizeable. If you can’t figure out which one, just make them all Serializeable until you figure it out. That is usually the cause of the UnmarshalException

It cant find IRemote because ist not available to the remote machine. It has to be available either locally in the classpath or through a URL accessible source to both machines

This can be for a numerb of reasons:

(1) YOu dont have a Jar with IRemote in the classpath on the remote mach9ne
(2) You DO have a Jar with IRemote in the classpath but its bot the same version as the one on the sending machine.
(3) You arent getting it on the cleitn side froma URL that is accessible to the server.

Not entirely sure why we are even dicussing RMi here though,.

RMI is pretty usless for games and certaonly more trouble then its worth.

ok, problem is solved, but im not really sure why:

i have to mention that for test purposes my rmi client/server-pait is one eclipse project
and shares the same /bin directory. the problem seemed to be, that i didnt define the
-Djava.rmi.server.codebase=“file:/ (…)” vm-argument.
i only gave the vm the location of the security-property file and a normal classpath.

what i can not understand is that im using the rmi.server.codebase argument the first
time but i already ran the example. i cant see a difference …