Exception in thread "main" java.rmi.ConnectException: Connection refused to host: 192.168.1.153; nested exception is:
java.net.ConnectException: Connection refused: connect
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:601)
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:198)
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:184)
at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:322)
at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
at java.rmi.Naming.rebind(Naming.java:160)
at rmi.compute.Bootstrap.main(Bootstrap.java:17)
这个问题是怎么产生的?
我的安全管理许可没有问题,我连接的是本机,
我的启动代码是这样的
if(System.getSecurityManager() == null){
System.setSecurityManager(new SecurityManager());
}
LocateRegistry.createRegistry(10990);
String name = "ComputeEngine";
ComputeEngine engine = new ComputeEngine();
System.out.println("ComputerEngine exported");
Naming.rebind(name, engine);
System.out.println("ComputeEngine bound");
假如,我在运行这个之前,先在cmd中运行rmiregistry就没有问题,我想问问,这是为什么?资料我找了很久都没有找到
Java 异常 rmi
------解决方案--------------------
Naming.rebind(name, engine);改为
Naming.rebind("rmi://192.168.1.153:10990/"+name, engine);