spring-projects / spring-projects/spring-modulith

EventListener in DelegatingEventExternalizer could not be created

Open
#973 6 comments 1 reaction 1 assignee View on GitHub

@odrotbohm is already working on this.

Since Dec 2, 2024.

in: event publication registry meta: waiting for feedback
Dominant language
Java
Stars
1.2k
Forks
222
PR merge metrics
No merged PRs in 30d

Description

When using Spring Modulith 1.2.5 (starter + events-core + events-kafka) with Spring Boot 3.3.5, the auto-configured DelegatingEventExternalizer instance 'kafkaEventExternalizer' appears to be created as a JdkProxy, which the EventListenerMethodProcessor can not find the @ApplicationModuleListener annotated method on, resulting in the following stacktrace:

org.springframework.beans.factory.BeanInitializationException: Failed to process @EventListener annotation on bean with name 'kafkaEventExternalizer': Need to invoke method 'externalize' declared on target class 'DelegatingEventExternalizer', but not found in any interface(s) of the exposed proxy type. Either pull the method up to an interface or switch to CGLIB proxies by enforcing proxy-target-class mode in your configuration.
	at org.springframework.context.event.EventListenerMethodProcessor.afterSingletonsInstantiated(EventListenerMethodProcessor.java:150)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:986)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:971)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:625)
	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)
	...
Caused by: java.lang.IllegalStateException: Need to invoke method 'externalize' declared on target class 'DelegatingEventExternalizer', but not found in any interface(s) of the exposed proxy type. Either pull the method up to an interface or switch to CGLIB proxies by enforcing proxy-target-class mode in your configuration.
	at org.springframework.core.MethodIntrospector.selectInvocableMethod(MethodIntrospector.java:135)
	at org.springframework.aop.support.AopUtils.selectInvocableMethod(AopUtils.java:146)
	at org.springframework.context.event.EventListenerMethodProcessor.processBean(EventListenerMethodProcessor.java:190)
	at org.springframework.context.event.EventListenerMethodProcessor.afterSingletonsInstantiated(EventListenerMethodProcessor.java:146)

I'll be glad to provide additional details as required!
This might very well be user error and not an actual bug, especially since this is the first interaction any of our team has had with Spring Modulith - but I could not find anything out of place. My apologies in advance

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.