Open tcrespog opened 9 months ago
Sorry, but the error seems to keep happening in Micronaut 4.3.2 (same steps to reproduce).
A workaround to force the usage of the Micronaut hibernate validator ConstraintValidatorFactory
is to create such as class:
package mn.hibernate.playground;
import io.micronaut.configuration.hibernate.validator.DefaultConstraintValidatorFactory;
import io.micronaut.context.BeanContext;
import io.micronaut.context.annotation.Replaces;
import jakarta.inject.Singleton;
import jakarta.validation.ConstraintValidatorFactory;
@Replaces(ConstraintValidatorFactory.class)
@Singleton
public class DefaultConstraintValidatorFactoryReplacement extends DefaultConstraintValidatorFactory {
public DefaultConstraintValidatorFactoryReplacement(BeanContext beanContext) {
super(beanContext);
}
}
Micronaut Framework BOM 4.3.3 will include Micronaut hibernate validator 4.2.1. We will release it by the end of the week.
However, you can force it now:
configurations.all {
resolutionStrategy {
force "io.micronaut.beanvalidation:micronaut-hibernate-validator:4.2.1"
}
}
If in a terminal running Micronaut CLI 4.3.2, I run
mn create-app -b gradle -l groovy -t spock --features=h2,jdbc-tomcat,data-jpa,hibernate-jpa,hibernate-validator mn-hibernate-playground.
then I force the micronaut-hibernate-validator to 4.2.1 with the above snippet.
I add a class such as:
package entities;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
@Entity
public class Book {
@Id
private Long id;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
}
and modify the JPA configuration to scan for entities with:
jpa.default.entity-scan.packages=entities
I can run ./gradle run
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:
Steps To Reproduce
mn create-app -b gradle -l groovy -t spock --features=h2,jdbc-tomcat,data-jpa,hibernate-jpa,hibernate-validator mn-hibernate-playground
../gradlew run
.Environment Information
Example Application
No response
Version
4.3.1