Java RMI – How to setup java.rmi.server.codebase in Eclipse

A typical problem when running and building java RMI Applications is the following Exception:

Registering server with rmiregistry
Error happened: RemoteException occurred in server thread; nested exception is: 
    java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is: 
    java.lang.ClassNotFoundException: com.ibm.pbo.rmi.HelloInterface

To handle that problem, you have to set the following JVM Argument when running the ServerApplication:

-Djava.rmi.server.codebase=file:/abc/def

When using Eclipse, you can set this Argument in the Run Configuration:

Right Click on the ServerApplication java file -> Run As -> Run Configuration

Go to the Arguments Tab and insert the codebase argument in the VM Arguments Section:

 

Be careful with the trailing slash at the end. This slash is NECESSARY.

When I tried to point to the src directory of my Project it did not work, but if it points to the bin directory it worked fine.

-Djava.rmi.server.codebase=file:/home/philboss/Projekte/Eclipse_workspace/JavaRMI/bin/

Have fun with Java RMI 🙂