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

Gradle task processAot fails when Bean Validation API present but no provider found #30130

Closed
abelsromero opened this issue Mar 16, 2023 · 0 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) theme: aot An issue related to Ahead-of-time processing type: regression A bug that is also a regression
Milestone

Comments

@abelsromero
Copy link
Contributor

We have a native application pulling jakarta.validation:jakarta.validation-api as a transitive dependency but not using Validation.
And the following failure appears during processAot task for Spring Boot 3.0.3 and 3.0.4, but not 3.0.2

~/...//spring-cloud-gateway-k8s >>> ./gradlew :scg-operator:processAot                                                                                                                                                                                                   

> Task :scg-operator:processAot
2023-03-16T10:54:24.913+01:00  INFO 99554 --- [           main] c.v.t.s.OperatorApplication              : Starting OperatorApplication using Java 17.0.6 with PID 99554 (/Users////spring-cloud-gateway-k8s/scg-operator/build/classes/java/main started by in /Users//work/code/spring-cloud-gateway-k8s/scg-operator)
Exception in thread "main" java.lang.ExceptionInInitializerErrorc.v.t.s.OperatorApplication              : No active profile set, falling back to 1 default profile: "default"
        at org.springframework.validation.beanvalidation.BeanValidationBeanRegistrationAotProcessor.processAheadOfTime(BeanValidationBeanRegistrationAotProcessor.java:59)
        at org.springframework.beans.factory.aot.BeanDefinitionMethodGeneratorFactory.getAotContributions(BeanDefinitionMethodGeneratorFactory.java:151)
        at org.springframework.beans.factory.aot.BeanDefinitionMethodGeneratorFactory.getBeanDefinitionMethodGenerator(BeanDefinitionMethodGeneratorFactory.java:99)
        at org.springframework.beans.factory.aot.BeanDefinitionMethodGeneratorFactory.getBeanDefinitionMethodGenerator(BeanDefinitionMethodGeneratorFactory.java:115)
        at org.springframework.beans.factory.aot.BeanRegistrationsAotProcessor.processAheadOfTime(BeanRegistrationsAotProcessor.java:48)
        at org.springframework.beans.factory.aot.BeanRegistrationsAotProcessor.processAheadOfTime(BeanRegistrationsAotProcessor.java:36)
        at org.springframework.context.aot.BeanFactoryInitializationAotContributions.getContributions(BeanFactoryInitializationAotContributions.java:67)
        at org.springframework.context.aot.BeanFactoryInitializationAotContributions.<init>(BeanFactoryInitializationAotContributions.java:49)
        at org.springframework.context.aot.BeanFactoryInitializationAotContributions.<init>(BeanFactoryInitializationAotContributions.java:44)
        at org.springframework.context.aot.ApplicationContextAotGenerator.lambda$processAheadOfTime$0(ApplicationContextAotGenerator.java:58)
        at org.springframework.context.aot.ApplicationContextAotGenerator.withCglibClassHandler(ApplicationContextAotGenerator.java:67)
        at org.springframework.context.aot.ApplicationContextAotGenerator.processAheadOfTime(ApplicationContextAotGenerator.java:53)
        at org.springframework.context.aot.ContextAotProcessor.performAotProcessing(ContextAotProcessor.java:106)
        at org.springframework.context.aot.ContextAotProcessor.doProcess(ContextAotProcessor.java:84)
        at org.springframework.context.aot.ContextAotProcessor.doProcess(ContextAotProcessor.java:49)
        at org.springframework.context.aot.AbstractAotProcessor.process(AbstractAotProcessor.java:82)
        at org.springframework.boot.SpringApplicationAotProcessor.main(SpringApplicationAotProcessor.java:80)
Caused by: jakarta.validation.NoProviderFoundException: Unable to create a Configuration, because no Jakarta Bean Validation provider could be found. Add a provider like Hibernate Validator (RI) to your classpath.
        at jakarta.validation.Validation$GenericBootstrapImpl.configure(Validation.java:291)
        at jakarta.validation.Validation.buildDefaultValidatorFactory(Validation.java:103)
        at org.springframework.validation.beanvalidation.BeanValidationBeanRegistrationAotProcessor$BeanValidationDelegate.<clinit>(BeanValidationBeanRegistrationAotProcessor.java:66)
        ... 17 more

It seems BeanValidationBeanRegistrationAotProcessor is too strict and while having the API without implementation is not useful I don't think is a common case when dealing with third-party dependencies (in this case io.swagger.core.v3:swagger-core).

Current workarounds:

  1. Excluding exclude (group: 'jakarta.validation', module: 'jakarta.validation-api') completely
  2. Adding implementation 'org.springframework.boot:spring-boot-starter-validation'
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Mar 16, 2023
@jhoeller jhoeller added type: regression A bug that is also a regression in: core Issues in core modules (aop, beans, core, context, expression) theme: aot An issue related to Ahead-of-time processing and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Mar 16, 2023
@jhoeller jhoeller added this to the 6.0.7 milestone Mar 16, 2023
@jhoeller jhoeller self-assigned this Mar 16, 2023
@jhoeller jhoeller changed the title Gradle task processAot fails when no jakarta validation implementation is found Gradle task processAot fails when Bean Validation API present but no provider found Mar 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) theme: aot An issue related to Ahead-of-time processing type: regression A bug that is also a regression
Projects
None yet
Development

No branches or pull requests

3 participants