2013-07-06 66 views
0

我正在RMI客戶端上工作,但是當我嘗試從任何機器連接到它但本地主機時,它會得到一個被拒絕的連接堆棧跟蹤。我證實我的防火牆已關閉。我還需要做什麼? 這裏是我的代碼如何在netbeans RMI

public class FrontManagerClient { 

    boolean state; 
    String command; 
    String value; 

    public FrontManagerClient(String cmd,String value) { 
     this.command=cmd; 
     this.value=value; 
    } 

    public boolean getCommand() throws RemoteException, NotBoundException, MalformedURLException{ 

     FrontPanelManagerIntrface f=(FrontPanelManagerIntrface)Naming.lookup("lookup=//localhost//frontPanelRequestControllerService"); 
     state=f.Communicate(command, value); 
     return state; 
    } 

    public static void main(String[] args) throws RemoteException, NotBoundException, MalformedURLException { 
     FrontManagerClient f = new FrontManagerClient("Password_Enter", "admin"); 
     System.out.println(""+f.getCommand()); 
    } 
} 

當我運行服務器和運行客戶端,它會顯示此錯誤消息

Exception in thread "main" java.rmi.ConnectException: Connection refused to host: 10.96.28.6; nested exception is: 
java.net.ConnectException: Connection refused: connect 
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:619) 
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:216) 
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:202) 
at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:340) 
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source) 
at java.rmi.Naming.lookup(Naming.java:101) 
at doormanager.FrontManagerClient.getCommand(FrontManagerClient.java:30) 
at doormanager.FrontManagerClient.main(FrontManagerClient.java:37) 
Caused by: java.net.ConnectException: Connection refused: connect 
at java.net.DualStackPlainSocketImpl.connect0(Native Method) 
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79) 
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339) 
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200) 
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182) 
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172) 
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) 
at java.net.Socket.connect(Socket.java:579) 
at java.net.Socket.connect(Socket.java:528) 
at java.net.Socket.<init>(Socket.java:425) 
at java.net.Socket.<init>(Socket.java:208) 
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:40) 
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:146) 
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:613) 
... 7 more 

Java結果:1

回答

1

沒有RMI註冊運行在主機10.96.28.6,或者你還沒有修復你的防火牆。