连接被拒绝托管:localhost

时间:2018-11-10 17:34:28

标签: java rmi connection-refused

java.rmi.ConnectException: Connection refused to host: localhost; 
nested exception is: 
java.net.ConnectException: Connection refused: connect

服务器代码:

TaxService taxService = new TaxService();
Registry registry = LocateRegistry.createRegistry(8889);
registry.bind("TaxService", taxService);
System.out.println("The server started");

客户代码:

Registry registry = null;
    try {
        registry = LocateRegistry.getRegistry("localhost", 8889);
    } catch (RemoteException e1) {
        e1.printStackTrace();
    }
    ITaxService taxService = null;
    try {
        taxService = (ITaxService) registry.lookup("TaxService");
    } catch (RemoteException e) {
        System.out.println(e);
    }

0 个答案:

没有答案