title: RMI with IP - ClassNotFoundException, UnmarshalException, ServerException
body: <p>there anyone who can help me with establishing rmi server using ip. I've been searching it for few days on the net, but cannot solve my problem.</p>
  
  <p>Client</p>
  
  <pre><code>public static void main(String[] agrcs) throws RemoteException, NotBoundException, MalformedURLException {
      if (System.getSecurityManager() == null) {     System.setProperty("java.security.policy", "F:\\škola\\pg2\\LodeSemestralka\\java.policy");
  
          System.setSecurityManager(new RMISecurityManager());
      }
      String ip = agrcs[0];
      Integer port = new Integer(agrcs[1]);
  
          server = (ShipServer) Naming.lookup("//"+ip+":"+port+"/"+SERVER_NAME);
  }
  </code></pre>
  
  <p>Server</p>
  
  <pre><code>static public void main(String[] agrcs) throws RemoteException {
      if (System.getSecurityManager() == null) {
          System.setProperty("java.security.policy", "F:\\škola\\pg2\\LodeSemestralka\\java.policy");
          System.setSecurityManager(new RMISecurityManager());
      }
  
      String ip = agrcs[0];
      Integer port = new Integer(agrcs[1]);
  
      playground = new Playground();
      try {
          Naming.bind("//" + ip + ":" + port + "/" + SERVER_NAME, playground);
      } catch (Exception ex) {
          playground = null;
          ex.printStackTrace();
      }
  </code></pre>
  
  <p>When servers is called, it throws</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: lode.gameCore.Playground
      at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:413)
      at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:267)
      at sun.rmi.transport.Transport$1.run(Transport.java:177)
      at sun.rmi.transport.Transport$1.run(Transport.java:174)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.rmi.transport.Transport.serviceCall(Transport.java:173)
      at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:553)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:808)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:667)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
      at java.lang.Thread.run(Thread.java:722)
      at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:273)
      at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:251)
      at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:377)
      at sun.rmi.registry.RegistryImpl_Stub.bind(Unknown Source)
      at java.rmi.Naming.bind(Naming.java:128)
      at server.Server.main(Server.java:38)
      at lode.game.StartUpScreen.createNewGame(StartUpScreen.java:186)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:601)
      at org.jdesktop.application.ApplicationAction.noProxyActionPerformed(ApplicationAction.java:662)
      at org.jdesktop.application.ApplicationAction.actionPerformed(ApplicationAction.java:698)
      at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
      at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
      at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
      at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
      at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
      at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:289)
      at java.awt.Component.processMouseEvent(Component.java:6504)
      at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
      at java.awt.Component.processEvent(Component.java:6269)
      at java.awt.Container.processEvent(Container.java:2229)
      at java.awt.Component.dispatchEventImpl(Component.java:4860)
      at java.awt.Container.dispatchEventImpl(Container.java:2287)
      at java.awt.Component.dispatchEvent(Component.java:4686)
      at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
      at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
      at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
      at java.awt.Container.dispatchEventImpl(Container.java:2273)
      at java.awt.Window.dispatchEventImpl(Window.java:2713)
      at java.awt.Component.dispatchEvent(Component.java:4686)
      at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:707)
      at java.awt.EventQueue.access$000(EventQueue.java:101)
      at java.awt.EventQueue$3.run(EventQueue.java:666)
      at java.awt.EventQueue$3.run(EventQueue.java:664)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
      at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
      at java.awt.EventQueue$4.run(EventQueue.java:680)
      at java.awt.EventQueue$4.run(EventQueue.java:678)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
      at java.awt.EventQueue.dispatchEvent(EventQueue.java:677)
      at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:211)
      at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
      at ....
  </code></pre>
  
  <p>and in lode.gameCore is <code>public interface ShipServer extends Remote {...}</code> and <code>public class Playground implements ShipServer, Serializable {...}</code></p>
  
  <p>I was using LocaleRegistry and it works perfectly but only on one PC. I need the application running on more PC using RMI with IP via the net, to communicate etc. </p>
  
  <p>And in java.policy is <code>grant {permission java.security.AllPermission;};</code></p>