RemoteException java.rmi.UnmarshalException: error unmarshalling return

I had a working RMI Client and Server for my Java class. I decided to place these into their own packages rather than running as a default package.

After I placed them in their own Packages the java.rmi.UnmarshalException: error unmarshalling return; nested exception is: java.lang.ClassNotFoundException: error started happening on connection,.

I put the programs back into the default package and it all started working again.

I realize that there is probably a technical reason for this, but this worked for me!


I had this problem because I had different package names in client and server code:

package my.pkg; 
// server side interface definition...

// ------------- //

package my.pkg.something;
// client side interface definition...

I changed the name of client-side package and set it as the name of server-side package:

package my.pkg; 
// server side interface definition...

// ------------- //

package my.pkg; // renamed to the name of package in server-side .
// client side interface definition...

and the problem went away.