Skip to content

Issues I encountered when using Spring Modulith #311

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

Open
MarkLehmacherInvestify opened this issue Sep 26, 2023 · 1 comment
Open

Issues I encountered when using Spring Modulith #311

MarkLehmacherInvestify opened this issue Sep 26, 2023 · 1 comment

Comments

@MarkLehmacherInvestify
Copy link

MarkLehmacherInvestify commented Sep 26, 2023

Hi there,

I investigated Spring Modulith, because it exactly fits my organisation's approach to organically growing a microservice architecture. Thank you very much for your work on Spring Modulith!

My first use case was to get @EnablePersistentDomainEvents working. To that end I included dependencies for spring-modulith-starter-jpa and spring-modulith-events-core (trying both 1.0.1 and 1.1.0-M1).

During my evaluation I encountered the following issues.

BeanDefinitionOverrideException: Invalid bean definition with name 'aggregateChangeEventHandle

org.springframework.beans.factory.support.BeanDefinitionOverrideException: Invalid bean definition with name 'aggregateChangeEventHandler' defined in class path resource [com/investify/product/bc_robo_advisor/change_management/configuration/AggregateChangeEventExecutorConfiguration.class]: Cannot register bean definition [Root bean: class [null]; scope=; abstract=false; lazyInit=null; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=aggregateChangeEventExecutorConfiguration; factoryMethodName=investmentLifecycleListenerTaskExecutor; initMethodNames=null; destroyMethodNames=[(inferred)]; defined in class path resource [com/investify/product/bc_robo_advisor/change_management/configuration/AggregateChangeEventExecutorConfiguration.class]] for bean 'aggregateChangeEventHandler' since there is already [Generic bean: class [com.investify.product.bc_robo_advisor.change_management.AggregateChangeEventHandler]; scope=singleton; abstract=false; lazyInit=null; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodNames=null; destroyMethodNames=null; defined in file [/Users/mlehmacher/Develop/investify-components/hybrid-onboarding/service/build/classes/java/main/com/investify/product/bc_robo_advisor/change_management/AggregateChangeEventHandler.class]] bound.

I don't know why this happens, my suspicion is the AutoConfiguration which extends the regular Configuration in combination with an AutoConfigurationPackage shrug

I wasn't able to fix this by any other way (Configuration exclusions, etc.) than generally allowing bean definition overrides:
spring.main.allow-bean-definition-overriding: true

JpaEventPublication Entity wasn't picked up

Cause of this was an @EntityScan on our main application class. Apparently there is a known issue with @EntityScan causing side effects on Entity discovery of auto configuration packages.

I just removed @EntityScan from our application class as the default behavior works for us.

JpaEventPublication#serializedEvent does not allow serializations with more than 255 chars and my persistence provider throws an exception if longer values are encountered

This is mainly an issue for tests. For production usage we can take care of serializedEvent allowing more chars by way of liquibase schema management.

As a workaround I duplicated org.springframework.modulith.events.jpa.JpaEventPublication into my the service source tree and added a @Column(length = 8000 ) annotation

AsyncUncaughtExceptionHandler not working with @async @TransactionalEventListener when @EnablePersistentDomainEvents is active

My custom exception handler is never called when uncatched Exceptions are encountered within a @async @TransactionalEventListener listener while @EnablePersistentDomainEvents is enabled. The custom exception handler gets called as soon as I disable persistent domain events.

@odrotbohm
Copy link
Member

The last of the listed issues should be solved by the fix for GH-372.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants