Problema com RMI!

3 respostas
F

Pessoal,

Estou fazendo uma aplicação didatica com RMI e estou com o seguinte problema :

java.rmi.UnmarshalException: Error unmarshaling return header; nested exception is: java.net.SocketException: No buffer space available (maximum connections reached?): recv failed at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source) at sun.rmi.server.UnicastRef.invoke(Unknown Source) at sun.rmi.registry.RegistryImpl_Stub.bind(Unknown Source) at java.rmi.Naming.bind(Unknown Source) at ChatImpl.main(ChatImpl.java:93) Caused by: java.net.SocketException: No buffer space available (maximum connections reached?): recv failed at java.net.SocketInputStream.socketRead0(Native Method) at java.net.SocketInputStream.read(Unknown Source) at java.io.BufferedInputStream.fill(Unknown Source) at java.io.BufferedInputStream.read(Unknown Source) at java.io.DataInputStream.readByte(Unknown Source) ... 5 more

Isso acontece de vez em quando … assim que eu starto o cliente ou o servidor ele nao consegue fazer o bind…

Ja tentei ate mudar o registro do Windows XP aumentando o numero de conexoes TCP e diminuindo o TIMEOUT delas … e mesmo assim acontece isso …

Alguem ja enfrentou este problema ?

Obrigado !

Faruk

3 Respostas

F

Ninguem ??? :frowning:

marianalarab

Olá! Você conseguiu resolver este problema? Porque eu estou com extamente a mesma exception agora.
O meu RMI consegue a conexão, mas quando vou chamar uma funcionalidade o erro ocorre.

Obrigada

INTERFACE:
public interface InterfaceServidorRMI extends java.rmi.Remote{

//Executa comandos Svn
public int execute(String comando)throws RemoteException;

//Tabela de arquivos
public List<Arquivo> selectArq(final BuscaTermos transferObject)throws RemoteException;

}

SERVER:

public class ServidorNomesRMI extends UnicastRemoteObject implements InterfaceServidorRMI{

/**
 * 
 */
private static final long serialVersionUID = 1L;

  public static void main(String[] args) {
	try {			
        ServidorNomesRMI im = new ServidorNomesRMI();
        System.err.println("\n\nDateServidor começando...");
        Registry r = LocateRegistry.createRegistry(Registry.REGISTRY_PORT);
        Naming.rebind("trafegaServidor", im);
        System.err.println("DateServido pronto no endereço: " + java.net.InetAddress.getLocalHost().getHostAddress());
    } catch (Exception e) {
        System.err.println(e);
        System.exit(1);
    }
}
public List<Arquivo> selectArq(BuscaTermos transferObject) {

ResultSet rs = null;

List<Arquivo> lista = new ArrayList<Arquivo>();

Connection conn = null;

PreparedStatement stmt = null;

String statement = null;

try {

conn = BDUtils.getConection();

statement = "SELECT " +

"IDARQUIVO, " +

"CAMINHO " +									

"FROM ARQUIVO WHERE " +

transferObject.getBuscapor() +

" = ? ";

System.out.println(statement);
stmt = conn.prepareStatement( statement );
        stmt.setString(1, transferObject.getTermos());
        rs = stmt.executeQuery();
        
        
        try {        	
			while(rs.next()){
				Arquivo arquivo = new Arquivo();				
				
				arquivo.setIdArquivo(rs.getInt("IDARQUIVO"));
				arquivo.setCaminho(rs.getString("CAMINHO"));
				
				lista.add(arquivo);
			}
		} catch (SQLException e) {			
			e.printStackTrace();
		}
		
    } catch (Exception e) {

		e.printStackTrace();
    } finally {
        try {
            if ( stmt != null ) {
                stmt.close();
            }
            if ( conn != null ) {
                conn.close();
            }
        } catch (Exception e) {
        	e.printStackTrace();
        }
    }
    
    
	return lista;
    
}


CLIENTE:

private boolean conectar( String ipSN ) {

System.out.println(INICIANDO int conectar( + ipSN + ));

try {

is = (InterfaceServidorRMI)Naming.lookup(rmi://” + ipSN + “/trafegaServidor”);

System.out.println(chamou o RMI do SERVIDOR\n);
//ComponenteDAO c = new ComponenteDAO();
        BuscaTermos bt = new BuscaTermos();
        bt.setBuscapor("Caminho");
        bt.setTermos("");
        List&lt;Componente&gt; lista = is.selectArq(bt); //Exception ocorre nesta linha******************************************* &lt;--
        
        for ( Componente i : lista ){
        	String comando = "svnserve -d -r C:\\" + i.getCaminho() + " --listen-port " + i.getPorta();
        	ThreadServerSvn thread = new ThreadServerSvn("Inicia",comando,is);
        	thread.start();
        }
        
    } catch (MalformedURLException ex) {
        ex.printStackTrace();
        System.out.println("erro no RMI do SERVIDOR\n");
        return false;
    } catch (RemoteException ex) {
        ex.printStackTrace();
        System.out.println("erro no RMI do SERVIDOR\n");
        return false;
    } catch (NotBoundException ex) {
        ex.printStackTrace();
        System.out.println("erro no RMI do SERVIDOR\n");
        return false;
    }
    return true;
}

O BEAN Arquivo está assim, e está presente tanto no projeto cliente quanto servidor. Dentro de pacotes com mesmo nome, assim como a interface.

public class Arquivo implements Serializable{

/**
 * 
 */
private static final long serialVersionUID = -7316253179873091202L;
private int IdArquivo;
private String Caminho;

public int getIdArquivo() {
	return IdArquivo;
}
public void setIdArquivo(int idArquivo) {
	IdArquivo = idArquivo;
}
public String getCaminho() {
	return Caminho;
}
public void setCaminho(String caminho) {
	Caminho = caminho;
}

}

fantomas

Oi,

Você já verificou se a mensagem do client chegou no server? (pode utilizar o debugger ou simplesmente o System.out.println)

Se a mensagem chegou no server, vc verificou se ele está retornando um conteúdo válido para o client?

Quando estudei rmi parece que tinha que colocar alguns arquivos resultantes da compilação do server no client, acho que eram os skeletons ou stubs não me lembro bem (talvez hoje não precise mais), você já revisou esta questão?

P.S Quando postar código utilize as tags [code] para melhorar a visualização.

flws

Criado 5 de setembro de 2006
Ultima resposta 29 de out. de 2008
Respostas 3
Participantes 3