Spring Cloud ZooKeeper Discovery Client Not Register on ZooKeeper when using SpringBootServletInitializer
See original GitHub issueI have a spring boot application that use spring-cloud-stater-zookeeper-discovery to register the service, but it doesn’t work.
-
the application is deployed as a WAR.
@SpringBootConfiguration @EnableAutoConfiguration @EnableDiscoveryClient public class MyApplication extends SpringBootServletInitializer { @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { return application.sources(MyApplication.class) .properties("spring.cloud.zookeeper.discovery.instance-host=" + getHostName()) .web(true); } }
-
the application has connected to the zookeeper instance. Ping messages to zookeeper can be seen in the application’s log and the output of
STAT
command shows a connected zookeeper client. -
the application does not register watchers to appointed zookeeper path, i.e.,
/services
. This can be confirmed by sendingWCHC
command to the zookeeper.
Spring Boot version: 1.5.9
spring-cloud-stater-zookeeper-discovery: 1.2.0.RELEASE
web container: tomcat 8.5.23
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:13 (4 by maintainers)
Top Results From Across the Web
Spring Cloud Zookeeper
This project provides Zookeeper integrations for Spring Boot applications through autoconfiguration and binding to the Spring Environment and other Spring ...
Read more >java - Issue with connecting zookeeper from spring boot with ...
We can notice the order of discovery clients are different in two servers, no sure because of this it's registering in tomcar and...
Read more >More than one implementation of @EnableDiscoveryClient-Apache ...
If I remove @EnableDiscoveryClient on spring boot, instance is connecting zookeeper but not registering. But I want to run this in JBOSS EAP...
Read more >An Intro to Spring Cloud Zookeeper - Baeldung
We will enable service registration by adding the spring-cloud-starter-zookeeper-discovery dependency and using the annotation ...
Read more >Microservices with Spring - DEV Community
Spring Cloud supports Netflix Eureka, Hashicorp Consul, and Apache Zookeeper. The Discovery Server may return the location of multiple ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I got the same issue with newer version:
I used suggested solution above by @spencergibb . I’m using properties to set the port so don’t need the first part.
@Autowired private ZookeeperAutoServiceRegistration serviceRegistration;
I also encountered a similar problem, mainly caused by the inconsistency of the ZooKeeper server and java client versions. Changing to a consistent version can solve the problem