Galera estou tentando rodar este servidor RMI mas obtenho o seguinte erro:
Erro: java.rmi.ConnectException: Connection refused to host: 10.1.1.54; nested exception is:
java.net.ConnectException: Connection refused: connect
e a classe servidor é esta:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package br.com.daikensoftware.rmi.servidor;
import br.com.daikensoftware.rmi.interfaces.InterfaceProc;
import br.com.daikensoftware.rmi.interfaces.InterfaceServidor;
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;
import java.util.HashMap;
import java.util.Map;
/**
*
* @author Filipe Sguarizi Panceri
*/
public class Servidor implements InterfaceServidor{
private int contClientes;
private Map clientesConectados = new HashMap();
//private ArrayList vetor = null;
public int estabeleceConexao() throws RemoteException
{
try
{
contClientes++;
clientesConectados.put(contClientes, (InterfaceProc) Naming.lookup("cliente"));
}
catch (Exception e)
{
System.out.println("Exception "+e.toString());
}
return contClientes;
}
public String liberaConexao(int idCliente) throws RemoteException
{
try
{
clientesConectados.remove(idCliente);
}
catch (Exception e)
{
}
return "Conexao Liberada";
}
public void sendToAll(String mensagem, int idCliente, String nome) throws RemoteException
{
try
{
((InterfaceProc) clientesConectados.get(idCliente)).atribuirMensagem("> "+ nome + " disse: "+mensagem);
}
catch (Exception e)
{
}
}
public static void main (String args[]){
try
{
Servidor servidor = new Servidor();
InterfaceServidor stub = (InterfaceServidor) UnicastRemoteObject.exportObject(servidor, 0);
Registry registry = LocateRegistry.getRegistry();
registry.bind("InterfaceServidor", stub);
System.out.println("Servidor Iniciado");
}
catch (Exception e)
{
System.out.println("Erro: "+e.toString());
}
}
}