question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Spring Cloud ZooKeeper Discovery Client Not Register on ZooKeeper when using SpringBootServletInitializer

See original GitHub issue

I have a spring boot application that use spring-cloud-stater-zookeeper-discovery to register the service, but it doesn’t work.

  1. 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);
         }
     }
     
  2. 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.

  3. the application does not register watchers to appointed zookeeper path, i.e., /services. This can be confirmed by sending WCHC 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:open
  • Created 6 years ago
  • Reactions:2
  • Comments:13 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
rodoc81commented, Nov 5, 2018

I got the same issue with newer version:

  • Spring Boot version: 2.1.0.RELEASE
  • spring-cloud-stater-zookeeper-discovery: 2.1.0.M1
  • web container: tomcat 8.5.34

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;

@EventListener(ApplicationStartedEvent.class)
public void init(final ApplicationStartedEvent event) {
    serviceRegistration.start();
}
0reactions
weihubeatscommented, Jan 4, 2022

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found