两台linux上架设rmi出现的奇怪问题
在两台linux下架设rmi经常会出现以下异常,Naming.lookup(url)中url的ip地址明明是server端的ip,可返回的信息却是被本机的ip拒绝,确实很怪异,异常如下:
java.rmi.ConnectException: Connection refused to host: 127.0.0.1; nested exception is: java.net.ConnectException: Connection refused
解决方法是在server端的代码中添加一行代码:
System.setProperty("java.rmi.server.hostname",server端的ip);//添加这行代码
LocateRegistry.createRegistry(1099);
RemoteImpl service = new RemoteImpl();
Naming.rebind("RmiServer", service);
java.rmi.ConnectException: Connection refused to host: 127.0.0.1; nested exception is: java.net.ConnectException: Connection refused
解决方法是在server端的代码中添加一行代码:
System.setProperty("java.rmi.server.hostname",server端的ip);//添加这行代码
LocateRegistry.createRegistry(1099);
RemoteImpl service = new RemoteImpl();
Naming.rebind("RmiServer", service);
相关推荐
ScarletLina 2014-05-12
GodLong 2011-06-09
agjllxchjy 2012-03-05
Bonbonwen 2011-11-17
LinuxCard 2012-10-10
XuNeely 2019-06-30
spring 2014-05-12
妖怪哪里跑 2014-03-13
lxfHaHaHa 2013-08-06
uk8692 2019-06-28
hanyujianke 2014-09-16
dlutbob 2010-06-01
RickyIT 2010-05-03
JESSIEfoo 2010-01-16
JESSIEfoo 2009-04-16
dananhai 2008-02-01