错误现象

在linux上部署RMI服务端程序后,测试无法通过,主要错误如下:

Exception in thread "main" org.springframework.remoting.RemoteConnectFailureException:
Could not connect to remote service [rmi://xxx];
nested exception is java.rmi.ConnectException: Connection refused to host: 127.0.0.1;
nested exception is: java.net.ConnectException: Connection refused: connect

错误原因

简单点说,是因为linux上通过hostname获取IP的机制而导致的问题。通过命令hostname -i 查看IP是多少。我看到的 是127.0.0.1。
也就是说:
“hostname -i”=127.0.0.1,看到的错误提示就是“Connection refused to host: 127.0.0.1”。
“hostname -i”=xxx,看到的错误提示就是“Connection refused to host: xxx”

修复办法

方法1(我认为的最好的办法):
启动程序时,添加参数-Djava.rmi.server.hostname=xxip。举例:

java -Djava.rmi.server.hostname=xxip -jar xx.jar

xxip为客户端能够正确访问的ip地址即可。

方法2:
修改linux系统设置,使hostname -i 返回的IP是客户端能够正确访问的ip地址。
具体方法:

cat /proc/sys/kernel/hostname //查看本机hostname是什么。比如是abc
vi /etc/hosts                 //新增一行或修改某一行: xxip  abc

Spring RMI错误:java.rmi.ConnectException: Connection refused to host: 127.0.0.1相关推荐

  1. IDEA点击download source 报错:Caused by: java.rmi.ConnectException: Connection refused to host: 127.0.0.1

    IDEA点击Download sources 报错:Caused by: java.rmi.ConnectException: Connection refused to host: 127.0.0. ...

  2. Ubuntu下RMI Server 抛出java.rmi.ConnectException: Connection refused to host: 127.0.0.1解决办法

    需要启动rmiregistry 参见 http://ubuntuforums.org/showthread.php?t=1278660 The actual reason is the rmiregi ...

  3. java.rmi.ConnectException: Connection refused to host:

    java.rmi.ConnectException: Connection refused to host: 127.0.0.1; nested exception is: java.net.Conn ...

  4. 解决: java.net.ConnectException: Connection refused: connect

    前些天发现了一个巨牛的人工智能学习网站,通俗易懂,风趣幽默,忍不住分享一下给大家.点击跳转到教程. java.net.ConnectException: Connection refused: con ...

  5. 解决java.net.ConnectException: Connection refused:connect报错

    解决java.net.ConnectException: Connection refused:connect报错 2. 原因和解决: 1)端口号被占用:杀死占用端口号(一般为8080)的进程,释放端 ...

  6. 问题:AmqpConnectException: java.net.ConnectException: Connection refused: connect

    一.问题:SpringCloud的Stream整合RabbitMQ org.springframework.amqp.AmqpConnectException: java.net.ConnectExc ...

  7. org.springframework.amqp.AmqpConnectException: java.net.ConnectException: Connection refused: connec

    1. 错误信息 org.springframework.amqp.AmqpConnectException: java.net.ConnectException: Connection refused ...

  8. ftp连接 java.net.ConnectException: Connection refused

    http://zhidao.baidu.com/question/245219177.html JAVA编写FTP连接报错java.net.ConnectException: Connection r ...

  9. 解决:RabbitMQ 连接报错:amqp.AmqpConnectException: java.net.ConnectException: Connection refused: connect

    前些天发现了一个巨牛的人工智能学习网站,通俗易懂,风趣幽默,忍不住分享一下给大家.点击跳转到教程. 1. springcloud 工程中 config-client 中使用到 RabbitMQ ,启动 ...

最新文章

  1. centos ezhttp mysql_CentOS安装mysq
  2. 使用crypto模块实现md5加密功能(解决中文加密前后端不一致的问题)
  3. mongodb 对内存的严重占用以及解决方法
  4. 求求你把输入法调小一点... | 今日最佳
  5. java compliance_java complier compliance level问题引发的思考
  6. shell中循环执行某个进程获取返回值,并循环执行直到函数出错
  7. 说说对javaee中的session的理解
  8. android adbd分析,android6.0 adbd深入分析(三)adb root重启adbd流程
  9. 深度学习框架间互操作的工具:MMdnn
  10. 计算机usb口设置方法,如何在电脑上设定usb端口权限
  11. win10更新完,每次重启电脑都提示 未安装任何音频输出设备
  12. Android APK瘦身优化
  13. 凯联医疗完成逾亿元C轮融资 加速布局微量药物输注领域
  14. 2021云计算技能竞赛真题卷(附标准答案)
  15. 更新下来的vue项目如何跑起来
  16. 概览:可视化前端测试
  17. u盘装服务器系统失败原因,u盘装系统引导失败原因及解决方案
  18. iOS-Bug收集:You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated
  19. 【ketlle】本地开发kitlle job提交至linux生产环境上执行流程
  20. Lua阿拉伯数字转中文大写数字

热门文章

  1. Effective C++ 条款47
  2. 汉文博士 0.5.6 正式版发布
  3. Android基于mAppWidget实现手绘地图(三)--环境搭建
  4. 封装的适配器 adapter
  5. 0207.Domino R8.0.x群集配置手册
  6. Linux 磁盘管理 二(Raid、LVM、Quota)
  7. Cisco 3550配置DHCP的实际经验
  8. oracle定时任务(dbms_job)
  9. ORACLE SQL:经典查询练手第三篇
  10. 深入理解 Ribbon-Hystrix-Feign 三者之间的关系(一)