title: How to pass object in arguments in RMI method?
body: <p>I am trying to add arguments in RMI method. When I add e.g. <code>String</code> everything works fine. But I am not sure if I can pass an object I created. I am new to RMI so my code is very simple:</p>
  
  <p>HelloIF</p>
  
  <pre><code>public interface HelloIF extends Remote {
      String greeting(Context c) throws RemoteException;
  }
  </code></pre>
  
  <p>Hello</p>
  
  <pre><code>public class Hello extends UnicastRemoteObject implements HelloIF {
  
      public Hello() throws RemoteException {
      }
  
      public String greeting(Context c) throws RemoteException {
          addToContext(c);
          report(c);
          return "greeting";
      }
  
      void addToContext(Context c) {
          c.addID(Thread.currentThread().getId());
      }
  
      void report(Context c) {
          System.out.println("Hello.greeting() thread : "
                  + Thread.currentThread().getName() + " "
                  + Thread.currentThread().getId());
  
          System.out.println("Hello.greeting() context : "
                  + c.getDistributedThreadName() + " " + c.getRequestType());
      }
  }
  </code></pre>
  
  <p>RMIServer</p>
  
  <pre><code>public class RMIServer {
  
      public static void main(String[] args) throws RemoteException, MalformedURLException {
          LocateRegistry.createRegistry(1099);
          HelloIF hello = new Hello();
          Naming.rebind("server.Hello", hello);
          System.out.println("server.RMI Server is ready.");
          System.out.println("RMIServer.main() thread : " + Thread.currentThread().getName() 
                  + " " + Thread.currentThread().getId());
      }
  }
  </code></pre>
  
  <p>RMIClient</p>
  
  <pre><code>public class RMIClient {
      public static void main(String[] args) throws RemoteException, MalformedURLException, NotBoundException {
  
          Context context = new Context("request1", Thread.currentThread().getName()+System.currentTimeMillis());
  
          Registry registry = LocateRegistry.getRegistry("localhost");
          HelloIF hello = (HelloIF) registry.lookup("server.Hello");
          System.out.println(hello.greeting(context));
          System.out.println("RMIClient.mian() thread : " + Thread.currentThread().getName() 
                  + " " + Thread.currentThread().getId());
      }
  }
  </code></pre>
  
  <p>and finally my class Context</p>
  
  <pre><code>public class Context 
  {
      private String requestType;
      private String distributedThreadName;
      private List&lt;Long&gt; IDList;
  
     (...) getters/setters
  }
  </code></pre>
  
  <p>What should I do to make passing Context possible? </p>