简体   繁体   English

Java RMI连接错误:未连接到本地主机

[英]Java RMI connection error: Not connecting to localhost

I am trying to connect to my localhost when running my application, but for some reason it tries to connect to an ip address other than my localhost. 我在运行应用程序时尝试连接到本地主机,但由于某种原因,它尝试连接到本地主机以外的IP地址。

Below is the error message I am getting. 以下是我收到的错误消息。 error 错误

I have looked at my hosts file and is mapped like below: 我查看了我的主机文件,并将其映射如下:

hostsfile hosts文件

As you are manually creating the Registry you could change the line 14 and 17 to 当您手动创建Registry ,可以将第1417行更改为

Registry registry = LocateRegistry.createRegistry(1099);

registry.bind("fileService", fs);

On the other hand Naming.rebind suppose to default the host to localhost but you could specify it anyway 另一方面, Naming.rebind假定默认将主机设置为localhost但是无论如何都可以指定它

Naming.rebind("//localhost/fileService", fs)

thought in that case the line with LocateRegistry.createRegistry is not necessary 认为在这种情况下,不需要与LocateRegistry.createRegistry的行

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM