项目

一般

简介

部署应用后,访问空白,提示 Caused by: java.net.SocketException: Invalid argument or cannot assign requested address

陈 泽豪大约 2 年 之前添加

版本:20210611

现象:

日志异常:

[2022-11-30T15:45:38] [] [SEVERE] [] [] [tid: _ThreadID=145 _ThreadName=ApusicLogManager] [timeMillis: 1669794338610] [levelValue: 1000] [[
  Caused by: javax.naming.CommunicationException [Root exception is java.rmi.ConnectIOException: Exception creating connection to: 0.0.0.1; nested exception is: 
    java.net.SocketException: Invalid argument or cannot assign requested address]]]
[2022-11-30T15:45:38] [] [WARNING] [NCLS-JMX-00007] [javax.enterprise.system.jmx] [tid: _ThreadID=145 _ThreadName=ApusicLogManager] [timeMillis: 1669794338607] [levelValue: 900] [[
  Cannot start JMX connector JmxConnector config: { name = system, Protocol = rmi_jrmp, Address = 0.0.0.0, Port = 6886, AcceptAll = false, AuthRealmName = admin-realm, SecurityEnabled = false} due to exception java.io.IOException: Cannot bind to URL [rmi://0.0.0.1:6886/jmxrmi]: javax.naming.CommunicationException [Root exception is java.rmi.ConnectIOException: Exception creating connection to: 0.0.0.1; nested exception is: 
    java.net.SocketException: Invalid argument or cannot assign requested address]]]

[2022-11-30T15:09:21] [] [SEVERE] [] [] [tid: _ThreadID=160 _ThreadName=ApusicLogManager] [timeMillis: 1669792161595] [levelValue: 1000] [[
  Caused by: java.net.SocketException: Invalid argument or cannot assign requested address]]

处理方案:

通过网上查询发现,这个可能和ipv6有关

添加相关-Djava.net.preferIPv4Stack=true的jvm参数

注意:旧版本可能不支持这个参数,所以最好可以换成新版——新版自带此参数