micronaut-projects / micronaut-projects/micronaut-sql
Multiple possible bean candidates found: [`DefaultInternalConstraintValidatorFactory`, `DefaultConstraintValidatorFactory`]
- Dominant language
- Java
- Stars
- 83
- Forks
- 49
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 22
Description
### Expected Behavior
No exception on starting up a default Micronaut Data + Hibernate JPA app.
### Actual Behaviour
The application fails to start with the following error:
```
ERROR io.micronaut.runtime.Micronaut - Error starting Micronaut server: Bean definition [org.hibernate.SessionFactory] could not be loaded: Error instantiating bean of type [io.micronaut.configuration.hibernate.jpa.conf.sessionfactory.configure.internal.ValidatorFactoryConfigurer]
Message: Multiple possible bean candidates found: [DefaultInternalConstraintValidatorFactory, DefaultConstraintValidatorFactory]
Path Taken: SessionFactoryPerDataSourceFactory.buildHibernateSessionFactoryBuilder(SessionFactoryBuilder sessionFactoryBuilder) --> new SessionFactoryPerDataSourceFactory(Environment environment,[List configures],StandardServiceRegistryBuilderCreator serviceRegistryBuilderSupplier,List standardServiceRegistryBuilderConfigurers,JpaConfiguration jpaConfiguration,ApplicationContext applicationContext,Integrator integrator) --> new ValidatorFactoryConfigurer([ValidatorFactory validatorFactory])
io.micronaut.context.exceptions.BeanInstantiationException: Bean definition [org.hibernate.SessionFactory] could not be loaded: Error instantiating bean of type [io.micronaut.configuration.hibernate.jpa.conf.sessionfactory.configure.internal.ValidatorFactoryConfigurer]
```
### Steps To Reproduce
1. Create a Micronaut Data + Hibernate JPA project using Micronaut 4.3.1: `mn create-app -b gradle -l groovy -t spock --features=h2,jdbc-tomcat,data-jpa,hibernate-jpa,hibernate-validator mn-hibernate-playground`.
2. Run the app: `./gradlew run`.
3. The app fails to start.
### Environment Information
- Ubuntu 22.04
- Java 17
### Example Application
_No response_
### Version
4.3.1
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the failure with the documented `mn create-app` command and `./gradlew run`. Trace `ValidatorFactoryConfigurer` and `SessionFactoryPerDataSourceFactory` from the reported stack to understand why both validator factory candidates are present; done means the default Micronaut Data + Hibernate JPA app starts without the ambiguous-candidate exception.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- database
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100