Skip to content

StreamsBuilderFactoryBean fails in a native image as org.apache.kafka.streams.errors.LogAndFailProcessingExceptionHandler cannot be loaded #3787

@wilkinsona

Description

@wilkinsona

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

Spring Kafka 3.3.4 with Apache Kafka 3.9.0

Describe the bug

2025-03-12T01:35:31.529Z  WARN 3731 --- [           main] o.s.c.support.GenericApplicationContext  : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'kafkaStreamsFunctionProcessorInvoker': Error creating bean with name 'stream-builder-process': null	
Application run failed	
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'kafkaStreamsFunctionProcessorInvoker': Error creating bean with name 'stream-builder-process': null	
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1812)	
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:601)	
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:523)	
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:339)	
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:347)	
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:337)	
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)	
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.instantiateSingleton(DefaultListableBeanFactory.java:1155)	
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingleton(DefaultListableBeanFactory.java:1121)	
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:1056)	
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:987)	
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:627)	
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752)	
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:439)	
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:318)	
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1361)	
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1350)	
	at com.example.cloud.stream.kafka.streams.SpringCloudStreamKafkaStreamsApplication.main(SpringCloudStreamKafkaStreamsApplication.java:42)	
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'stream-builder-process': null	
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1812)	
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:601)	
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:523)	
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:339)	
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:347)	
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:337)	
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:207)	
	at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1278)	
	at org.springframework.cloud.stream.binder.kafka.streams.AbstractKafkaStreamsBinderProcessor.buildStreamsBuilderAndRetrieveConfig(AbstractKafkaStreamsBinderProcessor.java:352)	
	at org.springframework.cloud.stream.binder.kafka.streams.KafkaStreamsFunctionProcessor.adaptAndRetrieveInboundArguments(KafkaStreamsFunctionProcessor.java:525)	
	at org.springframework.cloud.stream.binder.kafka.streams.KafkaStreamsFunctionProcessor.setupFunctionInvokerForKafkaStreams(KafkaStreamsFunctionProcessor.java:281)	
	at org.springframework.cloud.stream.binder.kafka.streams.function.KafkaStreamsFunctionProcessorInvoker.lambda$invoke$6(KafkaStreamsFunctionProcessorInvoker.java:95)	
	at [email protected]/java.util.Optional.ifPresent(Optional.java:178)	
	at org.springframework.cloud.stream.binder.kafka.streams.function.KafkaStreamsFunctionProcessorInvoker.invoke(KafkaStreamsFunctionProcessorInvoker.java:94)	
	at [email protected]/java.lang.reflect.Method.invoke(Method.java:569)	
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1916)	
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1869)	
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1808)	
	... 17 more	
Caused by: java.lang.ExceptionInInitializerError	
	at org.springframework.kafka.config.StreamsBuilderFactoryBean.createStreamBuilder(StreamsBuilderFactoryBean.java:454)	
	at org.springframework.kafka.config.StreamsBuilderFactoryBean.createInstance(StreamsBuilderFactoryBean.java:335)	
	at org.springframework.kafka.config.StreamsBuilderFactoryBean.createInstance(StreamsBuilderFactoryBean.java:68)	
	at org.springframework.beans.factory.config.AbstractFactoryBean.afterPropertiesSet(AbstractFactoryBean.java:142)	
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1859)	
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1808)	
	... 34 more	
Caused by: org.apache.kafka.common.config.ConfigException: Invalid value org.apache.kafka.streams.errors.LogAndFailProcessingExceptionHandler for configuration processing.exception.handler: Class org.apache.kafka.streams.errors.LogAndFailProcessingExceptionHandler could not be found.	
	at org.apache.kafka.common.config.ConfigDef.parseType(ConfigDef.java:778)	
	at org.apache.kafka.common.config.ConfigDef$ConfigKey.<init>(ConfigDef.java:1271)	
	at org.apache.kafka.common.config.ConfigDef$ConfigKey.<init>(ConfigDef.java:1237)	
	at org.apache.kafka.common.config.ConfigDef.define(ConfigDef.java:155)	
	at org.apache.kafka.common.config.ConfigDef.define(ConfigDef.java:198)	
	at org.apache.kafka.common.config.ConfigDef.define(ConfigDef.java:237)	
	at org.apache.kafka.common.config.ConfigDef.define(ConfigDef.java:399)	
	at org.apache.kafka.common.config.ConfigDef.define(ConfigDef.java:412)	
	at org.apache.kafka.streams.StreamsConfig.<clinit>(StreamsConfig.java:954)	
	... 40 more

To Reproduce

Run either cloud:cloud-stream-kafka-streams:nativeAppTest or integration:spring-kafka-streams:nativeAppTest in the main branch of the AOT smoke tests.

Expected behavior

The tests pass in a native image.

Sample

See the AOT smoke tests.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions