Open xiangyq000 opened 6 years ago
There is a similar problem in consul
Any workaround on this?
Maybe
@EventListener(ApplicationStartedEvent.class)
public void init(ApplicationStartedEvent event) {
ConfigurableApplicationContext context = event.getApplicationContext();
ZookeeperRegistration registration = context.getBean(ZookeeperRegistration.class);
registration.setPort(9080);
ZookeeperAutoServiceRegistration serviceRegistration = context.getBean(ZookeeperAutoServiceRegistration.class);
serviceRegistration.start();
}
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;
@EventListener(ApplicationStartedEvent.class)
public void init(final ApplicationStartedEvent event) {
serviceRegistration.start();
}
I have same issues, any one could help on this?
2019-01-24 07:15:43.006 ERROR 1 --- [nStateManager-0] o.a.c.x.d.details.ServiceDiscoveryImpl : Could not re-register instances after reconnection
java.lang.IllegalStateException: instance must be started before calling this method
at org.apache.curator.shaded.com.google.common.base.Preconditions.checkState(Preconditions.java:444) ~[curator-client-4.0.1.jar!/:na]
at org.apache.curator.framework.imps.CuratorFrameworkImpl.create(CuratorFrameworkImpl.java:416) ~[curator-framework-4.0.1.jar!/:4.0.1]
at org.apache.curator.x.discovery.details.ServiceDiscoveryImpl.internalRegisterService(ServiceDiscoveryImpl.java:236) ~[curator-x-discovery-4.0.1.jar!/:na]
at org.apache.curator.x.discovery.details.ServiceDiscoveryImpl.reRegisterServices(ServiceDiscoveryImpl.java:456) ~[curator-x-discovery-4.0.1.jar!/:na]
at org.apache.curator.x.discovery.details.ServiceDiscoveryImpl.access$100(ServiceDiscoveryImpl.java:58) ~[curator-x-discovery-4.0.1.jar!/:na]
at org.apache.curator.x.discovery.details.ServiceDiscoveryImpl$1.stateChanged(ServiceDiscoveryImpl.java:78) ~[curator-x-discovery-4.0.1.jar!/:na]
at org.apache.curator.framework.state.ConnectionStateManager$2.apply(ConnectionStateManager.java:274) [curator-framework-4.0.1.jar!/:4.0.1]
at org.apache.curator.framework.state.ConnectionStateManager$2.apply(ConnectionStateManager.java:270) [curator-framework-4.0.1.jar!/:4.0.1]
at org.apache.curator.framework.listen.ListenerContainer$1.run(ListenerContainer.java:93) [curator-framework-4.0.1.jar!/:4.0.1]
at org.apache.curator.shaded.com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:435) [curator-client-4.0.1.jar!/:na]
at org.apache.curator.framework.listen.ListenerContainer.forEach(ListenerContainer.java:85) [curator-framework-4.0.1.jar!/:4.0.1]
at org.apache.curator.framework.state.ConnectionStateManager.processEvents(ConnectionStateManager.java:268) [curator-framework-4.0.1.jar!/:4.0.1]
at org.apache.curator.framework.state.ConnectionStateManager.access$000(ConnectionStateManager.java:44) [curator-framework-4.0.1.jar!/:4.0.1]
at org.apache.curator.framework.state.ConnectionStateManager$1.call(ConnectionStateManager.java:120) [curator-framework-4.0.1.jar!/:4.0.1]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_111-internal]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_111-internal]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_111-internal]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_111-internal]
it seem that problem was here in EventListenerMethodProcessor, it does't work on SpringContainerClass who annotated @EventListner
private static boolean isSpringContainerClass(Class<?> clazz) {
return (clazz.getName().startsWith("org.springframework.") && !AnnotatedElementUtils.isAnnotated(ClassUtils.getUserClass(clazz), Component.class));
}
private void processBean(final String beanName, final Class<?> targetType) {
if (!this.nonAnnotatedClasses.contains(targetType) && !isSpringContainerClass(targetType)) {
...
//context#addApplicationListener
}
}
Hi,
Any update on this one ? I am facing the same issue when deploy the application as WAR.
If there are no comments then there are no updates
Is there any other workaround ?
Instead of @EventListener
class MyClass implements ApplicationListener<ApplicationStartedEvent> {
public void onApplicationEvent(ApplicationStartedEvent event) {
serviceRegistration.start();
}
}
I have the same issuse
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
I 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.
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