2016-11-20 25 views
0

フォーラムでこれまでに見つかったすべてのヒントを行っていますが、このエラーjava.rmi.ConnectException: Connection refused to host: 127.0.0.1; nested exception is: [java] java.net.ConnectException: Connection refused (Connection refused)が発生しています。RMI ConnectException:接続がホストに拒否されました:127.0.0.1

build.xmlファイル

<dirname property="basedir" file="." /> 

<target name="compile"> 
    <mkdir dir="${basedir}/bin" /> 
    <javac srcdir="${basedir}/src" destdir="${basedir}/bin" /> 
</target> 

<target name="clean" description="cleanup module"> 
    <delete dir="${basedir}/bin" /> 
</target> 

<target name="run" depends="compile"> 
    <parallel> 

     <java classpath="${basedir}/bin" classname="com.main.MainServer" 
      fork="true"> 
      <jvmarg value="-Djava.security.policy=server.policy" /> 
     </java> 

     <sequential> 
      <java classpath="${basedir}/bin" classname="com.main.MainClient"> 
       <jvmarg value="-Djava.security.policy=client.policy" /> 
      </java> 
     </sequential> 
    </parallel> 
</target> 

client.policy

grant{ 
     permission java.security.AllPermission; 
    }; 

のserver.policy

grant{ 
     permission java.security.AllPermission; 
    }; 

RMIレジストリを作成し、実行している

public void bindServer() { 
    if (System.getSecurityManager() == null) { 
     System.setSecurityManager(new SecurityManager()); 
    } 
    try { 
     System.setProperty("java.rmi.server.hostname", InetAddress.getLocalHost().getHostAddress()); 
     server = (IServer) UnicastRemoteObject.exportObject(new Server(), IConstant.RMI_PORT_SERVER); 
     Registry registry = LocateRegistry.createRegistry(IConstant.RMI_PORT_SERVER);         
     registry.rebind(IConstant.RMI_ID_SERVER, server); 
    } catch (RemoteException e) { 
     System.err.println("Server RemoteException:"); 
     e.printStackTrace(); 
     System.exit(1); 
    } catch (Exception e) { 
     e.printStackTrace(); 
     System.exit(1); 
    } 
} 

私の/ etc/hostsには、任意の助けが理解されるであろう

127.0.0.1 localhost 
127.0.0.1 mylaptop 
127.0.0.1 postgres 
127.0.0.1 java.rmi.server.hostname 

を提出します。

答えて

0

これは単なる試用する価値のあるものです。InetAddress.getLocalHost().getHostAddress()を印刷してみてください。私のマシンでは、127.0.0.1の代わりに127.0.1.1が返されます。

私は、これはいくつかのことをより明確にできたと考えている:あなたの返信用https://askubuntu.com/questions/754213/what-is-difference-between-localhost-address-127-0-0-1-and-127-0-1-1

+0

感謝。私はそれを試みました。 127.0.0.1を出力します。 –

関連する問題