Failed to register dubbo://192.168.137.1:20880/com.youfan.service.SayHelloService?anyhost=true&appli

dubbo注册zookeeper报错:

log4j:WARN No appenders could be found for logger (org.springframework.core.env.StandardEnvironment).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Exception in thread "main" java.lang.IllegalStateException: Failed to register dubbo://192.168.137.1:20880/com.youfan.service.SayHelloService?anyhost=true&application=dubbo-service-sayhello&dubbo=2.5.7&generic=false&interface=com.youfan.service.SayHelloService&methods=sayhello&pid=15080&side=provider&timestamp=1552277158207 to registry 192.168.137.128:2181, cause: Failed to register dubbo://192.168.137.1:20880/com.youfan.service.SayHelloService?anyhost=true&application=dubbo-service-sayhello&dubbo=2.5.7&generic=false&interface=com.youfan.service.SayHelloService&methods=sayhello&pid=15080&side=provider&timestamp=1552277158207 to zookeeper zookeeper://192.168.137.128:2181/com.alibaba.dubbo.registry.RegistryService?application=dubbo-service-sayhello&dubbo=2.5.7&interface=com.alibaba.dubbo.registry.RegistryService&pid=15080&timestamp=1552277158169, cause: Zookeeper is not connected yet!
	at com.alibaba.dubbo.registry.support.FailbackRegistry.register(FailbackRegistry.java:149)
	at com.alibaba.dubbo.registry.integration.RegistryProtocol.export(RegistryProtocol.java:120)
	at com.alibaba.dubbo.rpc.protocol.ProtocolListenerWrapper.export(ProtocolListenerWrapper.java:54)
	at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper.export(ProtocolFilterWrapper.java:92)
	at com.alibaba.dubbo.rpc.Protocol$Adaptive.export(Protocol$Adaptive.java)
	at com.alibaba.dubbo.config.ServiceConfig.doExportUrlsFor1Protocol(ServiceConfig.java:499)
	at com.alibaba.dubbo.config.ServiceConfig.doExportUrls(ServiceConfig.java:351)
	at com.alibaba.dubbo.config.ServiceConfig.doExport(ServiceConfig.java:312)
	at com.alibaba.dubbo.config.ServiceConfig.export(ServiceConfig.java:211)
	at com.alibaba.dubbo.config.spring.ServiceBean.onApplicationEvent(ServiceBean.java:122)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:167)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:393)
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:347)
	at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:883)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546)
	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93)
	at com.youfan.ProvideTest.main(ProvideTest.java:7)
Caused by: com.alibaba.dubbo.rpc.RpcException: Failed to register dubbo://192.168.137.1:20880/com.youfan.service.SayHelloService?anyhost=true&application=dubbo-service-sayhello&dubbo=2.5.7&generic=false&interface=com.youfan.service.SayHelloService&methods=sayhello&pid=15080&side=provider&timestamp=1552277158207 to zookeeper zookeeper://192.168.137.128:2181/com.alibaba.dubbo.registry.RegistryService?application=dubbo-service-sayhello&dubbo=2.5.7&interface=com.alibaba.dubbo.registry.RegistryService&pid=15080&timestamp=1552277158169, cause: Zookeeper is not connected yet!
	at com.alibaba.dubbo.registry.zookeeper.ZookeeperRegistry.doRegister(ZookeeperRegistry.java:112)
	at com.alibaba.dubbo.registry.support.FailbackRegistry.register(FailbackRegistry.java:136)
	... 18 more
Caused by: java.lang.IllegalStateException: Zookeeper is not connected yet!
	at com.alibaba.dubbo.remoting.zookeeper.zkclient.ZkClientWrapper.createPersistent(ZkClientWrapper.java:82)
	at com.alibaba.dubbo.remoting.zookeeper.zkclient.ZkclientZookeeperClient.createPersistent(ZkclientZookeeperClient.java:45)
	at com.alibaba.dubbo.remoting.zookeeper.support.AbstractZookeeperClient.create(AbstractZookeeperClient.java:47)
	at com.alibaba.dubbo.remoting.zookeeper.support.AbstractZookeeperClient.create(AbstractZookeeperClient.java:41)
	at com.alibaba.dubbo.remoting.zookeeper.support.AbstractZookeeperClient.create(AbstractZookeeperClient.java:41)
	at com.alibaba.dubbo.remoting.zookeeper.support.AbstractZookeeperClient.create(AbstractZookeeperClient.java:41)
	at com.alibaba.dubbo.registry.zookeeper.ZookeeperRegistry.doRegister(ZookeeperRegistry.java:110)
	... 19 more

解决办法:打开Linux系统防火墙中的2181端口

[root@yxy ~]# /sbin/iptables -I INPUT -p tcp --dport 2181 -j ACCEPT
原文地址:https://www.cnblogs.com/yangxianyang/p/13675614.html