spring-cloud / spring-cloud-stream

Framework for building Event-Driven Microservices
http://cloud.spring.io/spring-cloud-stream
Apache License 2.0
969 stars 595 forks source link

Cannot read field "internalTopologyBuilder" because "topology" is null #2966

Closed wrwksexahatvani closed 1 week ago

wrwksexahatvani commented 1 week ago

Describe the bug

When starting my apps an exception will be shown:

org.springframework.context.ApplicationContextException: Failed to start bean 'streamsBuilderFactoryManager'
    at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:288)
    at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:469)
    at java.base/java.lang.Iterable.forEach(Iterable.java:75)
    at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:257)
    at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:202)
    at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:981)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:627)
    at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.refresh(ReactiveWebServerApplicationContext.java:66)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754)
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:456)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:335)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1363)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1352)
    at at.wrwks.bef.stiegenauswahl.ApplicationKt.main(Application.kt:26)
Caused by: org.springframework.kafka.KafkaException: Could not start stream: 
    at org.springframework.cloud.stream.binder.kafka.streams.StreamsBuilderFactoryManager.start(StreamsBuilderFactoryManager.java:115)
    at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:285)
    ... 13 common frames omitted
Caused by: org.springframework.kafka.KafkaException: Could not start stream: 
    at org.springframework.kafka.config.StreamsBuilderFactoryBean.start(StreamsBuilderFactoryBean.java:383)
    at org.springframework.cloud.stream.binder.kafka.streams.StreamsBuilderFactoryManager.start(StreamsBuilderFactoryManager.java:105)
    ... 14 common frames omitted
Caused by: java.lang.NullPointerException: Cannot read field "internalTopologyBuilder" because "topology" is null
    at org.apache.kafka.streams.KafkaStreams.<init>(KafkaStreams.java:951)
    at org.apache.kafka.streams.KafkaStreams.<init>(KafkaStreams.java:857)
    at org.springframework.kafka.config.StreamsBuilderFactoryBean.start(StreamsBuilderFactoryBean.java:364)
    ... 15 common frames omitted

To Reproduce

I just upgraded to Spring Cloud 2023.0.1 with Spring Boot 3.3.1 with Kotlin 2.0 on Java 22 and every service fails to start.

Expected behavior

Services start as usual.

Sample

Will try to provide, but was hoping that based on the exception it will be obvious to the maintainers what's missing.

artembilan commented 1 week ago

Duplicate of https://github.com/spring-projects/spring-kafka/issues/3331. We will reopen this if we figure out the problem is on Spring Cloud Stream side.

artembilan commented 1 week ago

Reopen since looks like the problem is with multi-binder configuration, when SmartInitializingSingleton.afterSingletonsInstantiated() is not called for those binder-specific ApplicaitonContexts: https://github.com/spring-projects/spring-kafka/issues/3331

sobychacko commented 1 week ago

Can you upgrade to the latest spring-cloud release train (2023.0.2)? https://github.com/spring-cloud/spring-cloud-release/releases/tag/v2023.0.2. We introduced a fix in the 4.1.2 version of Spring Cloud Stream to accommodate the Spring Kafka changes. Closing the issue. Feel free to re-open if there is an issue.