Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wrwksexahatvani opened this issue Jun 26, 2024 · 4 comments
Closed

Comments

@wrwksexahatvani
Copy link

In what version(s) of Spring for Apache Kafka are you seeing this issue?

3.2.1

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
Copy link
Member

No, it is not obvious by the this stack trace what is going on.
According to the StreamsBuilderFactoryBean logic we got that this.topology property from here:

	public void afterSingletonsInstantiated() {
		try {
			this.topology = getObject().build(this.properties);

Apparently this StreamsBuilderFactoryBean bean is registered some non-standard way into an application context, so that afterSingletonsInstantiated() is not visible anymore.
Although, according to your stack trace, I see that this was a standard start from main:

	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)

So, some simple project to reproduce on our side would be great.
Thanks

@wrwksexahatvani
Copy link
Author

@artembilan I already have a dummy application in place, will pack it in a project. Downgrading Spring Boot to 3.2.5 worked around the issue and my services started.

@wrwksexahatvani
Copy link
Author

@artembilan The demo is available under https://github.com/andrashatvani/demo

@artembilan
Copy link
Member

Sorry, your application is too complex.
However it looks like you use multi-binder from Spring Cloud Stream.
As far as I know each binder in this case comes in its own application context.
So, that might be problem that the mentioned afterSingletonsInstantiated() is not called.

We made that change in the StreamsBuilderFactoryBean for some reasons: #3020

Apparently Spring Cloud Stream is not adapted to that.

So, closing this one in favor of that one in Spring Cloud Stream.

Thanks

@artembilan artembilan closed this as not planned Won't fix, can't repro, duplicate, stale Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants