Stopping an RMI server
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/241034/how-to-remotely-shutdown-a-java-rmi-server">How to remotely shutdown a Java RMI Server</a>  </p>
</blockquote>



<p>I have a problem in stopping the RMI server. From this class I call the method quit in this way:</p>

<pre><code>public static void shutdown() throws RemoteException
{
    Registry registry=LocateRegistry.getRegistry("localhost", 2000);
    {
        for(int i=0;i&lt;listaserver.size();i++)
        {
            String addr = (String)listaserver.get(i);
            try 
            {
                ServerInterface server = 
                    (ServerInterface)registry.lookup("//"+addr +"/SlaveServices");
                String ris = server.quit(addr);
                System.out.println(ris);
            } catch (NotBoundException ex) {
                System.out.println("Errore sull'oggetto remoto shutdown.");
            } catch (AccessException ex) {
                System.out.println("Errore sull'oggetto remoto shutdown - accesso.");  
            }
        }
</code></pre>

<p>And the method quit is in this class:</p>

<pre><code> public static String quit(String adrr)throws RemoteException {
   try {
        registry.unbind("//"+addr+"/SlaveServices");
        System.exit(1);

    } catch (NotBoundException ex) {
        Logger.getLogger(ServerStanze.class.getName()).log(Level.SEVERE, null, ex);
    } catch (AccessException ex) {
        Logger.getLogger(ServerStanze.class.getName()).log(Level.SEVERE, null, ex);
    }
    return "";
    }
</code></pre>

<p>But i always have the <code>UnmarshalException</code>. How can I fix this error?</p>
