问题描述
我正在尝试使用Jersey客户端连接到REST服务.
当我使用IPv4地址时,一切正常.
当我尝试用其IPv6替换服务器地址时,抛出以下异常:
I'm trying to connect using Jersey Client to a REST service.
When I'm using IPv4 address everything works fine.
When I'm trying to replace the server address with its IPv6 the following exception is thrown:
我尝试使用-Djava.net.preferIPv4Stack=false
和-Djava.net.preferIPv6Stack=true
运行,但没有帮助.
I tried running with -Djava.net.preferIPv4Stack=false
and -Djava.net.preferIPv6Stack=true
but it didn't help.
与IPv6相同的代码可在Weblogic的同一台计算机上使用.
The same code with IPv6 works on the same machine on Weblogic.
有什么建议吗?
推荐答案
通过设置-Djava.net.preferIPv4Stack=false
确实可以解决此问题,但是将其作为参数传递给./standalone.sh
是不够的,因为在standalone.conf
中重写了该值,并且standalone.sh
.
This problem indeed resolves by setting -Djava.net.preferIPv4Stack=false
, but passing it as an argument to ./standalone.sh
is not enough as this value is rewritten in standalone.conf
and standalone.sh
.
因此,应该做的是在两个文件中搜索-Djava.net.preferIPv4Stack=true
并将其修改为-Djava.net.preferIPv4Stack=false
.
Therefor, what should be done is searching for -Djava.net.preferIPv4Stack=true
inside both files and modifying them to -Djava.net.preferIPv4Stack=false
.
这篇关于JBoss 7.1.1上的Jesey Client抛出java.net.SocketException:协议族不适用于IPv6地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!