Spring云流应用程序启动程序在10秒后失败,说BinderException:无法初始化绑定器

时间:2017-11-16 07:40:32

标签: java spring-cloud-stream spring-kafka

我正在为twitter源运行一个Spring云流应用程序。 docker镜像成功启动,10Secs失败后抛出org.apache.kafka.common.errors.TimeoutException:60000 ms后无法更新元数据。

查看完整堆栈跟踪,

2017-11-16 06:41:33,293  INFO main o.a.k.c.u.AppInfoParser:83 - Kafka version : 0.10.1.1
2017-11-16 06:41:33,294  INFO main o.a.k.c.u.AppInfoParser:84 - Kafka commitId : f10ef2720b03b247
2017-11-16 06:51:39,822 ERROR main o.s.c.s.b.k.p.KafkaTopicProvisioner:253 - Cannot initialize Binder
org.apache.kafka.common.errors.TimeoutException: Failed to update metadata after 60000 ms.
2017-11-16 06:51:39,822  WARN main o.s.b.c.e.AnnotationConfigEmbeddedWebApplicationContext:550 - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Failed to start bean 'outputBindingLifecycle'; nested exception is org.springframework.cloud.stream.binder.BinderException: Cannot initialize binder:
2017-11-16 06:51:39,825  INFO main o.s.i.m.IntegrationMBeanExporter:449 - Unregistering JMX-exposed beans on shutdown
2017-11-16 06:51:39,825  INFO main o.s.i.m.IntegrationMBeanExporter:241 - Unregistering JMX-exposed beans
2017-11-16 06:51:39,825  INFO main o.s.i.m.IntegrationMBeanExporter:375 - Summary on shutdown: output
2017-11-16 06:51:39,825  INFO main o.s.i.m.IntegrationMBeanExporter:375 - Summary on shutdown: nullChannel
2017-11-16 06:51:39,825  INFO main o.s.i.m.IntegrationMBeanExporter:375 - Summary on shutdown: errorChannel
2017-11-16 06:51:39,825  INFO main o.s.i.m.IntegrationMBeanExporter:378 - Summary on shutdown: _org.springframework.integration.errorLogger.handler
2017-11-16 06:51:39,826  INFO main o.s.j.e.a.AnnotationMBeanExporter:449 - Unregistering JMX-exposed beans on shutdown
2017-11-16 06:51:39,826  INFO main o.s.j.e.a.AnnotationMBeanExporter:241 - Unregistering JMX-exposed beans
2017-11-16 06:51:39,827  INFO main o.s.s.c.ThreadPoolTaskScheduler:203 - Shutting down ExecutorService 'taskScheduler'
2017-11-16 06:51:39,827  INFO main o.s.c.a.AnnotationConfigApplicationContext:987 - Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@ba1f559: startup date [Thu Nov 16 06:41:26 GMT 2017]; parent: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@131276c2
2017-11-16 06:51:39,829  INFO main o.a.c.c.StandardService:179 - Stopping service Tomcat
2017-11-16 06:51:39,993  INFO main o.s.b.a.l.AutoConfigurationReportLoggingInitializer:101 - 

Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2017-11-16 06:51:40,172 ERROR main o.s.b.SpringApplication:815 - Application startup failed
org.springframework.context.ApplicationContextException: Failed to start bean 'outputBindingLifecycle'; nested exception is org.springframework.cloud.stream.binder.BinderException: Cannot initialize binder:
    at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:178) ~[spring-context-4.3.7.RELEASE.jar!/:4.3.7.RELEASE]
    at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:50) ~[spring-context-4.3.7.RELEASE.jar!/:4.3.7.RELEASE]
    at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:348) ~[spring-context-4.3.7.RELEASE.jar!/:4.3.7.RELEASE]
    at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:151) ~[spring-context-4.3.7.RELEASE.jar!/:4.3.7.RELEASE]
    at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:114) ~[spring-context-4.3.7.RELEASE.jar!/:4.3.7.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:879) ~[spring-context-4.3.7.RELEASE.jar!/:4.3.7.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:144) ~[spring-boot-1.5.2.RELEASE.jar!/:1.5.2.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:545) ~[spring-context-4.3.7.RELEASE.jar!/:4.3.7.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.2.RELEASE.jar!/:1.5.2.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:737) [spring-boot-1.5.2.RELEASE.jar!/:1.5.2.RELEASE]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:370) [spring-boot-1.5.2.RELEASE.jar!/:1.5.2.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:314) [spring-boot-1.5.2.RELEASE.jar!/:1.5.2.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1162) [spring-boot-1.5.2.RELEASE.jar!/:1.5.2.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1151) [spring-boot-1.5.2.RELEASE.jar!/:1.5.2.RELEASE]
    at org.springframework.cloud.stream.app.twitterstream.source.kafka.TwitterstreamSourceKafka10Application.main(TwitterstreamSourceKafka10Application.java:29) [classes!/:1.2.0.RELEASE]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_74]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_74]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_74]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_74]
    at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [twitterstream-source-kafka-10.jar:1.2.0.RELEASE]
    at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [twitterstream-source-kafka-10.jar:1.2.0.RELEASE]
    at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [twitterstream-source-kafka-10.jar:1.2.0.RELEASE]
    at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51) [twitterstream-source-kafka-10.jar:1.2.0.RELEASE]
Caused by: org.springframework.cloud.stream.binder.BinderException: Cannot initialize binder:
    at org.springframework.cloud.stream.binder.kafka.provisioning.KafkaTopicProvisioner.getPartitionsForTopic(KafkaTopicProvisioner.java:254) ~[spring-cloud-stream-binder-kafka-core-1.2.0.RELEASE.jar!/:1.2.0.RELEASE]
    at org.springframework.cloud.stream.binder.kafka.KafkaMessageChannelBinder.createProducerMessageHandler(KafkaMessageChannelBinder.java:148) ~[spring-cloud-stream-binder-kafka-1.2.0.RELEASE.jar!/:1.2.0.RELEASE]
    at org.springframework.cloud.stream.binder.kafka.KafkaMessageChannelBinder.createProducerMessageHandler(KafkaMessageChannelBinder.java:87) ~[spring-cloud-stream-binder-kafka-1.2.0.RELEASE.jar!/:1.2.0.RELEASE]
    at org.springframework.cloud.stream.binder.AbstractMessageChannelBinder.doBindProducer(AbstractMessageChannelBinder.java:109) ~[spring-cloud-stream-1.2.1.RELEASE.jar!/:1.2.1.RELEASE]
    at org.springframework.cloud.stream.binder.AbstractMessageChannelBinder.doBindProducer(AbstractMessageChannelBinder.java:55) ~[spring-cloud-stream-1.2.1.RELEASE.jar!/:1.2.1.RELEASE]
    at org.springframework.cloud.stream.binder.AbstractBinder.bindProducer(AbstractBinder.java:152) ~[spring-cloud-stream-1.2.1.RELEASE.jar!/:1.2.1.RELEASE]
    at org.springframework.cloud.stream.binding.BindingService.bindProducer(BindingService.java:125) ~[spring-cloud-stream-1.2.1.RELEASE.jar!/:1.2.1.RELEASE]
    at org.springframework.cloud.stream.binding.BindableProxyFactory.bindOutputs(BindableProxyFactory.java:238) ~[spring-cloud-stream-1.2.1.RELEASE.jar!/:1.2.1.RELEASE]
    at org.springframework.cloud.stream.binding.OutputBindingLifecycle.start(OutputBindingLifecycle.java:57) ~[spring-cloud-stream-1.2.1.RELEASE.jar!/:1.2.1.RELEASE]
    at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:175) ~[spring-context-4.3.7.RELEASE.jar!/:4.3.7.RELEASE]
    ... 22 common frames omitted
Caused by: org.apache.kafka.common.errors.TimeoutException: Failed to update metadata after 60000 ms.

kafka版本: kafka_2.10-0.10.1.0

我也使用kafka-10兼容的泊坞窗图像。

1 个答案:

答案 0 :(得分:0)

问题得到解决。这是与卡夫卡的连接问题。

我的监听器配置为listeners=PLAINTEXT://localhost:9092

我试图从其他节点连接。当我将侦听器配置替换为listeners=PLAINTEXT://<hostname>:9092时,错误就消失了。

但我不确定为什么spring cloud stream app不会在启动时抛出异常。!!!