可能的解决方式
配置正常,zk 启动正常,但是就是连接不上 看下是否是你的项目使用 JDK 版本过高 我这里使用的是 17 ,调成 1.8 版本即可
问题概述
provider 配置如下
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dubbo="http://dubbo.apache.org/schema/dubbo"
xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<context:property-placeholder/>
<dubbo:application name="demo-provider"/>
<dubbo:registry address="zookeeper://127.0.0.1:2181"/>
<dubbo:provider token="true"/>
<bean id="demoService" class="com.dyinggq.dubbo3simpledemo.basic.impl.DemoServiceImpl"/>
<dubbo:service interface="com.dyinggq.dubbo3simpledemo.basic.api.DemoService" ref="demoService"/>
</beans>
报错如下图
16:09:43.754 [main-SendThread(127.0.0.1:2181)] WARN org.apache.zookeeper.ClientCnxn - Session 0x0 for server 127.0.0.1/<unresolved>:2181, unexpected error, closing socket connection and attempting reconnect
java.nio.channels.UnresolvedAddressException: null
at java.base/sun.nio.ch.Net.checkAddress(Net.java:149)
at java.base/sun.nio.ch.Net.checkAddress(Net.java:157)
at java.base/sun.nio.ch.SocketChannelImpl.checkRemote(SocketChannelImpl.java:816)
at java.base/sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:839)
at org.apache.zookeeper.ClientCnxnSocketNIO.registerAndConnect(ClientCnxnSocketNIO.java:277)
at org.apache.zookeeper.ClientCnxnSocketNIO.connect(ClientCnxnSocketNIO.java:287)
at org.apache.zookeeper.ClientCnxn$SendThread.startConnect(ClientCnxn.java:1021)
at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1064)
16:09:43.757 [main-SendThread(127.0.0.1:2181)] DEBUG org.apache.zookeeper.ClientCnxnSocketNIO - Ignoring exception during shutdown input
java.net.SocketException: Socket is not connected
at java.base/sun.nio.ch.Net.translateToSocketException(Net.java:181)
at java.base/sun.nio.ch.Net.translateException(Net.java:217)
at java.base/sun.nio.ch.Net.translateException(Net.java:223)
at java.base/sun.nio.ch.SocketAdaptor.shutdownInput(SocketAdaptor.java:392)
at org.apache.zookeeper.ClientCnxnSocketNIO.cleanup(ClientCnxnSocketNIO.java:200)
at org.apache.zookeeper.ClientCnxn$SendThread.cleanup(ClientCnxn.java:1250)
at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1174)
Caused by: java.nio.channels.NotYetConnectedException: null
at java.base/sun.nio.ch.SocketChannelImpl.shutdownInput(SocketChannelImpl.java:1098)
at java.base/sun.nio.ch.SocketAdaptor.shutdownInput(SocketAdaptor.java:390)
... 3 common frames omitted
16:09:43.757 [main-SendThread(127.0.0.1:2181)] DEBUG org.apache.zookeeper.ClientCnxnSocketNIO - Ignoring exception during shutdown output
java.net.SocketException: Socket is not connected
at java.base/sun.nio.ch.Net.translateToSocketException(Net.java:181)
at java.base/sun.nio.ch.Net.translateException(Net.java:217)
at java.base/sun.nio.ch.Net.translateException(Net.java:223)
at java.base/sun.nio.ch.SocketAdaptor.shutdownOutput(SocketAdaptor.java:401)
at org.apache.zookeeper.ClientCnxnSocketNIO.cleanup(ClientCnxnSocketNIO.java:207)
at org.apache.zookeeper.ClientCnxn$SendThread.cleanup(ClientCnxn.java:1250)
at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1174)
Caused by: java.nio.channels.NotYetConnectedException: null
at java.base/sun.nio.ch.SocketChannelImpl.shutdownOutput(SocketChannelImpl.java:1115)
at java.base/sun.nio.ch.SocketAdaptor.shutdownOutput(SocketAdaptor.java:399)
... 3 common frames omitted
16:09:44.867 [main-SendThread(127.0.0.1:2181)] INFO org.apache.zookeeper.ClientCnxn - Opening socket connection to server 127.0.0.1/<unresolved>:2181. Will not attempt to authenticate using SASL (unknown error)
16:09:44.867 [main-SendThread(127.0.0.1:2181)] WARN org.apache.zookeeper.ClientCnxn - Session 0x0 for server 127.0.0.1/<unresolved>:2181, unexpected error, closing socket connection and attempting reconnect
java.nio.channels.UnresolvedAddressException: null
at java.base/sun.nio.ch.Net.checkAddress(Net.java:149)
at java.base/sun.nio.ch.Net.checkAddress(Net.java:157)
at java.base/sun.nio.ch.SocketChannelImpl.checkRemote(SocketChannelImpl.java:816)
at java.base/sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:839)
at org.apache.zookeeper.ClientCnxnSocketNIO.registerAndConnect(ClientCnxnSocketNIO.java:277)
at org.apache.zookeeper.ClientCnxnSocketNIO.connect(ClientCnxnSocketNIO.java:287)
at org.apache.zookeeper.ClientCnxn$SendThread.startConnect(ClientCnxn.java:1021)
at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1064)
16:09:44.868 [main-SendThread(127.0.0.1:2181)] DEBUG org.apache.zookeeper.ClientCnxnSocketNIO - Ignoring exception during shutdown input
java.net.SocketException: Socket is not connected
at java.base/sun.nio.ch.Net.translateToSocketException(Net.java:181)
at java.base/sun.nio.ch.Net.translateException(Net.java:217)
at java.base/sun.nio.ch.Net.translateException(Net.java:223)
at java.base/sun.nio.ch.SocketAdaptor.shutdownInput(SocketAdaptor.java:392)
at org.apache.zookeeper.ClientCnxnSocketNIO.cleanup(ClientCnxnSocketNIO.java:200)
at org.apache.zookeeper.ClientCnxn$SendThread.cleanup(ClientCnxn.java:1250)
at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1174)
Caused by: java.nio.channels.NotYetConnectedException: null
at java.base/sun.nio.ch.SocketChannelImpl.shutdownInput(SocketChannelImpl.java:1098)
at java.base/sun.nio.ch.SocketAdaptor.shutdownInput(SocketAdaptor.java:390)
... 3 common frames omitted
16:09:44.868 [main-SendThread(127.0.0.1:2181)] DEBUG org.apache.zookeeper.ClientCnxnSocketNIO - Ignoring exception during shutdown output
java.net.SocketException: Socket is not connected
at java.base/sun.nio.ch.Net.translateToSocketException(Net.java:181)
at java.base/sun.nio.ch.Net.translateException(Net.java:217)
at java.base/sun.nio.ch.Net.translateException(Net.java:223)
at java.base/sun.nio.ch.SocketAdaptor.shutdownOutput(SocketAdaptor.java:401)
at org.apache.zookeeper.ClientCnxnSocketNIO.cleanup(ClientCnxnSocketNIO.java:207)
at org.apache.zookeeper.ClientCnxn$SendThread.cleanup(ClientCnxn.java:1250)
at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1174)
Caused by: java.nio.channels.NotYetConnectedException: null
at java.base/sun.nio.ch.SocketChannelImpl.shutdownOutput(SocketChannelImpl.java:1115)
at java.base/sun.nio.ch.SocketAdaptor.shutdownOutput(SocketAdaptor.java:399)
... 3 common frames omitted
16:09:45.975 [main-SendThread(127.0.0.1:2181)] INFO org.apache.zookeeper.ClientCnxn - Opening socket connection to server 127.0.0.1/<unresolved>:2181. Will not attempt to authenticate using SASL (unknown error)
16:09:45.975 [main-SendThread(127.0.0.1:2181)] WARN org.apache.zookeeper.ClientCnxn - Session 0x0 for server 127.0.0.1/<unresolved>:2181, unexpected error, closing socket connection and attempting reconnect
|