想问一个有关rmi测试的问题,困扰我多时了:
我有一个远程接口HelloService同时我有2个实现了此接口并接继承UnicastRemoteObject的类HelloServiceImpl1,HelloServiceImpl2
然后在服务器段测试下代码:
HelloServiceImpl1 helloService1=new HelloServiceImpl1();
HelloServiceImpl2 helloService2=new HelloServiceImpl2();
Context namingContext=new InitialContext();
namingContext.rebind("rmi://localhost:1099/helloService1", helloService1);
namingContext.rebind("rmi://localhost:1099/helloService2", helloService2);
System.out.println("服务器注册了2个HelloService对象");
报错:
javax.naming.ServiceUnavailableException :Connection refused to host: localhost;
不知什么原因,请前辈指教!
答案越详细越好,不要照书抄!谢谢!
我有一个远程接口HelloService同时我有2个实现了此接口并接继承UnicastRemoteObject的类HelloServiceImpl1,HelloServiceImpl2
然后在服务器段测试下代码:
HelloServiceImpl1 helloService1=new HelloServiceImpl1();
HelloServiceImpl2 helloService2=new HelloServiceImpl2();
Context namingContext=new InitialContext();
namingContext.rebind("rmi://localhost:1099/helloService1", helloService1);
namingContext.rebind("rmi://localhost:1099/helloService2", helloService2);
System.out.println("服务器注册了2个HelloService对象");
报错:
javax.naming.ServiceUnavailableException :Connection refused to host: localhost;
不知什么原因,请前辈指教!
答案越详细越好,不要照书抄!谢谢!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货