title: JDK8 RMI server not working in JDK9 or JDK10 - ClassNotFoundException
body: <p>I have a very simple RMI client/server application that has been working perfectly well on different versions of JDK, up to JDK8. All of a sudden, it does not work anymore after updating to JDK9 or JDK10.  There must be some change in JKD9 and JDK10, probably related to the codebase property, that I have been unable to find.
  No changes neither in the code, nor in the classpath, codebase, java.policy. Nothing. Only upgrading to JDK10 and the server crashes.</p>
  
  <p>The error is the typical one when the codebase is not correct.</p>
  
  <p><strong><em>java.rmi.UnmarshallException:error unmarshalling arguments</em></strong>
  <strong><em>java.lang.ClassNotFoundException.</em></strong></p>
  
  <p>This is the code, which is very very silly.
  We have a remote interface, IServer.java</p>
  
  <pre><code>package sd.rmi.server;
  import java.rmi.Remote;
  import java.rmi.RemoteException;
  public interface IServer extends Remote {
   String sayHello() throws RemoteException;
  }
  </code></pre>
  
  <p>Then we have the class that implements the remote interface.</p>
  
  <pre><code>package sd.rmi.server;
  import java.rmi.RemoteException;
  import java.rmi.registry.LocateRegistry;
  import java.rmi.registry.Registry;
  import java.rmi.server.UnicastRemoteObject;
  
  public class Server implements IServer {
  private static final long serialVersionUID = 1L;
  protected Server() throws RemoteException {
      super();
  }
  
  public String sayHello() {
      return "Hello World!";
  }
  
  public static void main(String[] args) {
  
      if (System.getSecurityManager() == null) {
          System.setSecurityManager(new SecurityManager());
      }
      String name = "//" + args[0] + ":" + args[1] + "/" + args[2];
      try {       
          IServer objServer = new Server();
          IServer stubServer = (IServer) UnicastRemoteObject.exportObject(objServer,0);
          Registry registry = LocateRegistry.getRegistry();
          registry.rebind(name, stubServer);
          System.out.println("* Server '" + name + "' active and waiting...");
      } catch (Exception e) {
          System.err.println("- Exception running the server: " + e.getMessage());
          e.printStackTrace();
      }
  }
  }
  </code></pre>
  
  <p>The project structure is simple. There is basedir, named exampleRMI. Then we have exampleRMI\src for the java classes. Then exampleRMI\bin for the bytecodes, and exampleRMI\security for the java.policy and the policy is </p>
  
  <pre><code>grant {
      permission java.security.AllPermission;
  };
  </code></pre>
  
  <p>Then we have an ANT build.xml file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="no"?&gt;
  &lt;project basedir="." name="2.2_exampleRMI_Server"&gt;    
  &lt;property name="source.dir" location="src"/&gt;
  &lt;property name="build.dir" location="bin"/&gt;
  &lt;property name="classpath" location="bin"/&gt;
  &lt;property name="server.port" value="1099"/&gt; 
  &lt;property name="server.IP" value="127.0.0.1"/&gt;
  &lt;property name="server.Name" value="HelloServer"/&gt;
  &lt;property name="policy.file" location="security/java.policy"/&gt;  
  
  
  
  &lt;target name="build" description="Builds the project"&gt;
      &lt;delete dir="${build.dir}"/&gt;
      &lt;mkdir dir="${build.dir}"/&gt;
      &lt;javac srcdir="${source.dir}" destdir="${build.dir}" classpath="${classpath}" deprecation="true" fork="true" includeAntRuntime="no"/&gt;
  &lt;/target&gt;
  
  &lt;target name="server" description="Runs the Server"&gt;
      &lt;java classname="sd.rmi.server.Server" classpath="${classpath}" fork="true"&gt;
          &lt;jvmarg value="-Djava.rmi.server.codebase=file:${build.dir}/"/&gt;
          &lt;jvmarg value="-Djava.security.policy=${policy.file}"/&gt; 
          &lt;jvmarg value="-Djava.rmi.server.useCodebaseOnly=false"/&gt;           
          &lt;arg value="${server.IP}"/&gt; 
          &lt;arg value="${server.port}"/&gt; 
          &lt;arg value="${server.Name}"/&gt; 
      &lt;/java&gt;
  &lt;/target&gt;
  </code></pre>
  
  <p></p>
  
  <p>Then we launch the rmiregistry </p>
  
  <pre><code>rmiregistry -J-Djava.rmi.server.useCodebaseOnly=false
  </code></pre>
  
  <p>And the tiny application using</p>
  
  <pre><code>ant build server
  </code></pre>
  
  <p>Any help will be very much welcome.</p>