title: Java RMI ServerException - java.lang.ClassNotFoundException: org.prog.rmi.RmiServer_Stub
body: <p>I have inherited some Java RMI client/server code, and while it runs fine on one machine, I haven't been able to get it to run in my dev environment.</p>
  
  <p>The problem is when I run the server using the following <code>java.exe -Djava.security.policy=conf\server.policy -SRC;. -Djava.library.path=. org.prog.rmi.RmiServer</code></p>
  
  <p>I get the following error:</p>
  
  <pre><code>java.rmi.ServerException: RemoteException occurred in server thread; nested exception is: 
  java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is: 
  java.lang.ClassNotFoundException: org.prog.rmi.RmiServer_Stub (no security manager: RMI class loader disabled)
      at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:396)
      at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:250)
      at sun.rmi.transport.Transport$1.run(Transport.java:159)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
      at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649)
      ...
  </code></pre>
  
  <p>My <code>server.policy</code> file is</p>
  
  <pre><code>grant {
      permission java.security.AllPermission;
  };
  </code></pre>
  
  <p>And my java code:</p>
  
  <pre><code>        package org.prog.rmi;
  
          import java.rmi.Naming;
          import java.rmi.RemoteException;
          import java.rmi.RMISecurityManager;
          import java.rmi.server.UnicastRemoteObject;
          import java.rmi.registry.*; 
  
          public class RmiServer extends UnicastRemoteObject 
              implements RmiServerIntf {
  
          private BatchApi bapi;
          private String iniFileLocation;
          private String layoutOption;
          private int addressCount = 0;
          private RefInt apiHandle = new RefInt();
  
  
          public RmiServer(String iniFileLocation,String layoutOption) throws RemoteException 
          {   super();
              this.iniFileLocation = iniFileLocation;
              this.layoutOption = layoutOption;
              initAPI();
              startupAPI();
              openAPI();      
          }
  
          public static void main(String args[]) 
          {
              System.out.println("RMI server started");
  
              // Create and install a security manager
              if (System.getSecurityManager() == null) 
              {
                  System.setSecurityManager(new RMISecurityManager());
                  System.out.println("Security manager installed.");
              }
              else
                  System.out.println("Security manager already exists.");
  
              try  //special exception handler for registry creation
              {
                  LocateRegistry.createRegistry(1099); 
                  System.out.println("java RMI registry created.");
              }
              catch (RemoteException e)
              {
                  //do nothing, error means registry already exists
                  System.out.println("java RMI registry already exists.");
              }
  
              try
              {
                  //Instantiate RmiServer
                  for (String arg: args){
                      System.out.println(arg);
                  }
  
                  RmiServer obj = new RmiServer(args[0],args[1]);
  
                  // Bind this object instance to the name "RmiServer"
                  Naming.rebind("//127.0.0.1/RmiServer", obj);
                  System.out.println("PeerServer bound in registry");
  
              } 
              catch (Exception e) 
              {
                  System.err.println("RMI server exception:");
                  e.printStackTrace();
              }
          }    
  }
  </code></pre>
  
  <p>I've seen solutions relating to the <code>java.rmi.server.codebase</code> but didn't have any luck setting this either</p>