相关组件版本:
dubbo 2.7.12
zookeeper 3.6.3
使用dubbo zookeeper,之前已经测试完毕,记得当时因为Zookeeper连接问题折腾了好久。
这次使用,照搬上次的配置,结果报错
Session 0x0 for server 127.0.0.1/
22:40:08.920 [restartedMain] INFO o.a.z.ZooKeeper - [logEnv,100] - Client environment:java.io.tmpdir=C:\Users\yuming\AppData\Local\Temp\
22:40:08.920 [restartedMain] INFO o.a.z.ZooKeeper - [logEnv,100] - Client environment:java.compiler=
22:40:08.920 [restartedMain] INFO o.a.z.ZooKeeper - [logEnv,100] - Client environment:os.name=Windows 10
22:40:08.920 [restartedMain] INFO o.a.z.ZooKeeper - [logEnv,100] - Client environment:os.arch=amd64
22:40:08.920 [restartedMain] INFO o.a.z.ZooKeeper - [logEnv,100] - Client environment:os.version=10.0
22:40:08.920 [restartedMain] INFO o.a.z.ZooKeeper - [logEnv,100] - Client environment:user.name=yuming
22:40:08.921 [restartedMain] INFO o.a.z.ZooKeeper - [logEnv,100] - Client environment:user.home=C:\Users\yuming
22:40:08.921 [restartedMain] INFO o.a.z.ZooKeeper - [logEnv,100] - Client environment:user.dir=D:\DevelopProjectJava\otMgr-Cloud
22:40:08.922 [restartedMain] INFO o.a.z.ZooKeeper - [,442] - Initiating client connection, connectString=127.0.0.1:2181 sessionTimeout=60000 watcher=org.apache.curator.ConnectionState@4786f1b8
22:40:08.935 [restartedMain] INFO o.a.c.f.i.CuratorFrameworkImpl - [start,332] - Default schema
22:40:08.935 [restartedMain-SendThread(127.0.0.1:2181)] INFO o.a.z.ClientCnxn - [logStartConnect,1029] - Opening socket connection to server 127.0.0.1/:2181. Will not attempt to authenticate using SASL (unknown error)
22:40:08.939 [restartedMain-SendThread(127.0.0.1:2181)] WARN o.a.z.ClientCnxn - [run,1168] - Session 0x0 for server 127.0.0.1/:2181, unexpected error, closing socket connection and attempting reconnect
java.nio.channels.UnresolvedAddressException: null
at java.base/sun.nio.ch.Net.checkAddress(Net.java:139)
at java.base/sun.nio.ch.SocketChannelImpl.checkRemote(SocketChannelImpl.java:727)
at java.base/sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:741)
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)
22:40:10.044 [restartedMain-SendThread(127.0.0.1:2181)] INFO o.a.z.ClientCnxn - [logStartConnect,1029] - Opening socket connection to server 127.0.0.1/:2181. Will not attempt to authenticate using SASL (unknown error)
22:40:10.044 [restartedMain-SendThread(127.0.0.1:2181)] WARN o.a.z.ClientCnxn - [run,1168] - Session 0x0 for server 127.0.0.1/:2181, unexpected error, closing socket connection and attempting reconnect
java.nio.channels.UnresolvedAddressException: null
at java.base/sun.nio.ch.Net.checkAddress(Net.java:139)
at java.base/sun.nio.ch.SocketChannelImpl.checkRemote(SocketChannelImpl.java:727)
at java.base/sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:741)
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)
22:40:11.162 [restartedMain-SendThread(127.0.0.1:2181)] INFO o.a.z.ClientCnxn - [logStartConnect,1029] - Opening socket connection to server 127.0.0.1/:2181. Will not attempt to authenticate using SASL (unknown error)
22:40:11.162 [restartedMain-SendThread(127.0.0.1:2181)] WARN o.a.z.ClientCnxn - [run,1168] - Session 0x0 for server 127.0.0.1/:2181, unexpected error, closing socket connection and attempting reconnect
java.nio.channels.UnresolvedAddressException: null
at java.base/sun.nio.ch.Net.checkAddress(Net.java:139)
at java.base/sun.nio.ch.SocketChannelImpl.checkRemote(SocketChannelImpl.java:727)
at java.base/sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:741)
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)
22:40:11.953 [restartedMain] INFO o.a.c.h.Http11NioProtocol - [log,173] - Pausing ProtocolHandler ["http-nio-127.0.0.1-18821"]
22:40:11.953 [restartedMain] INFO o.a.c.c.StandardService - [log,173] - Stopping service [Tomcat]
22:40:11.976 [restartedMain] INFO o.a.c.h.Http11NioProtocol - [log,173] - Stopping ProtocolHandler ["http-nio-127.0.0.1-18821"]
22:40:11.982 [restartedMain] INFO o.a.c.h.Http11NioProtocol - [log,173] - Destroying ProtocolHandler ["http-nio-127.0.0.1-18821"]
22:40:12.031 [restartedMain] ERROR o.s.b.SpringApplication - [reportFailure,856] - Application run failed
java.lang.IllegalStateException: zookeeper not connected
at org.apache.dubbo.remoting.zookeeper.curator.CuratorZookeeperClient.(CuratorZookeeperClient.java:84)
at org.apache.dubbo.remoting.zookeeper.curator.CuratorZookeeperTransporter.createZookeeperClient(CuratorZookeeperTransporter.java:26)
at org.apache.dubbo.remoting.zookeeper.support.AbstractZookeeperTransporter.connect(AbstractZookeeperTransporter.java:70)
at org.apache.dubbo.remoting.zookeeper.ZookeeperTransporter$Adaptive.connect(ZookeeperTransporter$Adaptive.java)
at org.apache.dubbo.configcenter.support.zookeeper.ZookeeperDynamicConfiguration.(ZookeeperDynamicConfiguration.java:66)
at org.apache.dubbo.configcenter.support.zookeeper.ZookeeperDynamicConfigurationFactory.createDynamicConfiguration(ZookeeperDynamicConfigurationFactory.java:37)
at org.apache.dubbo.common.config.configcenter.AbstractDynamicConfigurationFactory.lambda$getDynamicConfiguration$0(AbstractDynamicConfigurationFactory.java:39)
at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1708)
at org.apache.dubbo.common.config.configcenter.AbstractDynamicConfigurationFactory.getDynamicConfiguration(AbstractDynamicConfigurationFactory.java:39)
at org.apache.dubbo.common.config.configcenter.DynamicConfiguration.getDynamicConfiguration(DynamicConfiguration.java:224)
at org.apache.dubbo.config.bootstrap.DubboBootstrap.prepareEnvironment(DubboBootstrap.java:1023)
at org.apache.dubbo.config.bootstrap.DubboBootstrap.startConfigCenter(DubboBootstrap.java:619)
at org.apache.dubbo.config.bootstrap.DubboBootstrap.initialize(DubboBootstrap.java:521)
at org.apache.dubbo.config.bootstrap.DubboBootstrap.start(DubboBootstrap.java:880)
at org.apache.dubbo.config.spring.context.DubboBootstrapApplicationListener.onContextRefreshedEvent(DubboBootstrapApplicationListener.java:70)
at org.apache.dubbo.config.spring.context.DubboBootstrapApplicationListener.onApplicationContextEvent(DubboBootstrapApplicationListener.java:63)
at com.alibaba.spring.context.OnceApplicationContextEventListener.onApplicationEvent(OnceApplicationContextEventListener.java:52)
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:426)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:383)
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:943)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:591)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:144)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:767)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:426)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:326)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1311)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1300)
at com.OtMetadataServiceApplication.main(OtMetadataServiceApplication.java:15)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
Caused by: java.lang.IllegalStateException: zookeeper not connected
at org.apache.dubbo.remoting.zookeeper.curator.CuratorZookeeperClient.(CuratorZookeeperClient.java:81)
... 36 common frames omitted
INFO [DubboShutdownHook:70] 2021-07-24 22:40:12,036 - [DUBBO] Run shutdown hook now., dubbo version: 2.7.12, current host: 172.24.160.1
INFO [AbstractRegistryFactory:93] 2021-07-24 22:40:12,048 - [DUBBO] Close all registries [], dubbo version: 2.7.12, current host: 172.24.160.1
INFO [DubboBootstrap:1315] 2021-07-24 22:40:12,053 - [DUBBO] DubboBootstrap is about to shutdown..., dubbo version: 2.7.12, current host: 172.24.160.1
INFO [LoggingEventListener:42] 2021-07-24 22:40:12,061 - [DUBBO] Dubbo Service has been destroyed., dubbo version: 2.7.12, current host: 172.24.160.1
INFO [DubboShutdownHook:70] 2021-07-24 22:40:12,061 - [DUBBO] Run shutdown hook now., dubbo version: 2.7.12, current host: 172.24.160.1
INFO [LoggingEventListener:42] 2021-07-24 22:40:12,061 - [DUBBO] Dubbo Service has been destroyed., dubbo version: 2.7.12, current host: 172.24.160.1
INFO [DubboShutdownHook:70] 2021-07-24 22:40:12,061 - [DUBBO] Run shutdown hook now., dubbo version: 2.7.12, current host: 172.24.160.1
INFO [LoggingEventListener:42] 2021-07-24 22:40:12,062 - [DUBBO] Dubbo Service has been destroyed., dubbo version: 2.7.12, current host: 172.24.160.1
22:40:12.076 [restartedMain] INFO c.a.d.p.DruidDataSource - [close,2043] - {dataSource-0} closing ...
而之前的测试例程运行依然正常。一一比对pom.xml引用和版本,java文件中的用法,完全一致。但依然报上面的错误。
后来忽然想到看看jdk的版本,结果正常的使用的jdk 1.8,出错的使用的jdk14,改到jdk1.8之后正常。
上次调试时,好像jdk1.8的还出过问题,使用的是131的版本,升级后才正常。目前使用的版本
java: jdk1.8.0_291
其他配置如下:
pom.xml
org.apache.dubbo
dubbo-spring-boot-starter
2.7.12
org.apache.dubbo
dubbo-dependencies-zookeeper
2.7.12
pom
idea工程:
在本机上安装有多个jdk版本时,切记次配置。
完整Demo地址与使用注意事项:
https://github.com/PascalMing/dubboZookeeperDemo
使用dubbo/zookeeper构建完整的服务端与客户端Demo
使用普通服务和mybatis访问mysql数据库两种示例供参考
dubbo 2.7.12
zookeeper 3.6.3
jdk 1.8.0 291
demo基于本机环境验证通过
如果跨服务器,务必保证防火墙的策略允许访问
dubbo/zookeeper/jdk 版本兼容性一般,请务必确保使用的版本之间是兼容的。也可以在此版本基础上升级测试