spring-projects / spring-projects/spring-modulith
Issues I encountered when using Spring Modulith
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.2k
- Forks
- 222
- PR merge metrics
- No merged PRs in 30d
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the reported behavior with spring-modulith-starter-jpa, spring-modulith-events-core, and @EnablePersistentDomainEvents. Investigate the named AggregateChangeEventExecutorConfiguration, JpaEventPublication, @EntityScan, and @Async @TransactionalEventListener cases separately. Done means each issue has a confirmed scope, an identified cause, and tests or documented behavior for the relevant fix.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring, spring-boot
- Domain
- backend, database
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100