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

EventListener in DelegatingEventExternalizer could not be created #973

Open
paulharkink opened this issue Nov 29, 2024 · 4 comments
Open
Assignees
Labels
in: event publication registry Event publication registry meta: waiting for feedback Waiting for feedback of the original reporter

Comments

@paulharkink
Copy link

paulharkink commented Nov 29, 2024

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

@odrotbohm
Copy link
Member

Can you provide a reproducer for the exception? I wonder what triggers the proxy creation for DelegatingEventExternalizer in the first place.

@odrotbohm odrotbohm self-assigned this Dec 2, 2024
@odrotbohm odrotbohm added in: event publication registry Event publication registry meta: waiting for feedback Waiting for feedback of the original reporter labels Dec 2, 2024
@paulharkink
Copy link
Author

Hi! Thanks for having a look. I was able to minimise and clean up our project so that it's just enough to reproduce the issue, please see the attached zip.
issue973.zip

@paulharkink
Copy link
Author

I wanted to provide an update and seek some guidance. As our project has grown and we've incorporated modulith-starter-mongodb, we've noticed some changes in behavior:

  1. The original DelegatingEventExternalizer exception no longer occurs when enabling externalization with Kafka configuration. However, events are still not being sent to Kafka.

  2. The EventPublicationRegistry is only attempting to markComplete events rather than store them first.

These issues, along with others we've encountered, are making it challenging to fully leverage Modulith in our project. I've tried to isolate the problems but haven't identified any clear conflicts in dependencies or configuration.

I recognize that the issue tracker might not be the ideal place for broader discussions, but I'm unsure where else to turn for comprehensive support on Modulith. Are there any resources or channels you'd recommend for discussing overall experiences and troubleshooting?

Additionally, are there any known incompatibilities or common configuration pitfalls that might explain the behaviors we're seeing? I'd be happy to provide more detailed information or a comprehensive test case if that would be helpful.

Lastly, given that my team is growing concerned about the challenges we're facing with Modulith, any insights or suggestions would be greatly appreciated. Thank you for your time and assistance.

@odrotbohm
Copy link
Member

odrotbohm commented Dec 10, 2024

I am unable to run the example project. After adding execution permissions to gradlew I still get:

-bash: ./gradlew: cannot execute: required file not found

Looking at the source code, I don't understand how it's supposed to reproduce any of the things you report here. The project doesn't use the event publication registry and there's no code whatsoever actually triggering any events. Can you please provide a sample project and ideally a single command I need to run to reproduce the alleged misbehavior? Unless the problems are tied to Kotlin and/or Gradle, I'd prefer a Java- and Maven-based project, as then, both Kotlin and Gradle can be ruled out as the source of any problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: event publication registry Event publication registry meta: waiting for feedback Waiting for feedback of the original reporter
Projects
None yet
Development

No branches or pull requests

2 participants