一个本机RMI测试例子程序

tg008007x3 2010-06-09 11:43:00
想问一个有关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;
不知什么原因,请前辈指教!
答案越详细越好,不要照书抄!谢谢!
...全文
154 12 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
tg008007x3 2010-06-09
  • 打赏
  • 举报
回复
和客户端代码没关系吧,我只写了个服务器端的,jdk是1.6的
龙四 2010-06-09
  • 打赏
  • 举报
回复
客户端代码发来看看

另外,jdk版本是多少,1.4是需要生成存根和骨架才能用的
pywepe 2010-06-09
  • 打赏
  • 举报
回复
RMI甚是不懂 惭愧
tg008007x3 2010-06-09
  • 打赏
  • 举报
回复
没有发布到服务器上 我就本机测试的。
tg008007x3 2010-06-09
  • 打赏
  • 举报
回复
改成127.0.0.1还是报错,昏死。
dr_lou 2010-06-09
  • 打赏
  • 举报
回复
看着像是个连接的异常啊。你把localhost改成ip试试。
eimhee 2010-06-09
  • 打赏
  • 举报
回复
有没有发布到服务器上?
黎某人 2010-06-09
  • 打赏
  • 举报
回复
sf 友情帮顶
tg008007x3 2010-06-09
  • 打赏
  • 举报
回复
我日 10楼大哥说滴太对了 我按照你滴说滴果然没错 给分了。
xiaweinixxw 2010-06-09
  • 打赏
  • 举报
回复
我也觉得是jdk有点问题
dr_lou 2010-06-09
  • 打赏
  • 举报
回复
tg008007x3 2010-06-09
  • 打赏
  • 举报
回复
没有人看看么?谁解答出来100分直接送之!

62,635

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧