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

Update logging level in BeanValidationBeanRegistrationAotProcessor for validation exceptions #31147

Closed
adsafawqew opened this issue Aug 31, 2023 · 9 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: enhancement A general enhancement
Milestone

Comments

@adsafawqew
Copy link

spring boot 3.1.3
gradle native plugin 0.9.25

processAot gradle task

...anValidationBeanRegistrationAotProcessor : Skipping validation constraint hint inference for bean queryDslQuerydslPredicateOperationCustomizer
java.lang.TypeNotPresentException: Type com.querydsl.core.types.Path not present
	at java.base/sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(CoreReflectionFactory.java:117) ~[na:na]
	at java.base/sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:125) ~[na:na]
	at java.base/sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49) ~[na:na]
	at java.base/sun.reflect.generics.visitor.Reifier.reifyTypeArguments(Reifier.java:68) ~[na:na]
	at java.base/sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:138) ~[na:na]
	at java.base/sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49) ~[na:na]
	at java.base/sun.reflect.generics.repository.MethodRepository.computeReturnType(MethodRepository.java:75) ~[na:na]
	at java.base/sun.reflect.generics.repository.MethodRepository.getReturnType(MethodRepository.java:66) ~[na:na]
	at java.base/java.lang.reflect.Method.getGenericReturnType(Method.java:297) ~[na:na]
	at org.hibernate.validator.internal.properties.javabean.JavaBeanMethod.<init>(JavaBeanMethod.java:20) ~[hibernate-validator-8.0.1.Final.jar:8.0.1.Final]
	at org.hibernate.validator.internal.properties.javabean.JavaBeanHelper.executable(JavaBeanHelper.java:133) ~[hibernate-validator-8.0.1.Final.jar:8.0.1.Final]
	at org.hibernate.validator.internal.properties.javabean.JavaBeanHelper.executable(JavaBeanHelper.java:121) ~[hibernate-validator-8.0.1.Final.jar:8.0.1.Final]
	at org.hibernate.validator.internal.properties.javabean.JavaBeanHelper.executable(JavaBeanHelper.java:113) ~[hibernate-validator-8.0.1.Final.jar:8.0.1.Final]
	at org.hibernate.validator.internal.metadata.provider.AnnotationMetaDataProvider.findExecutableMetaData(AnnotationMetaDataProvider.java:307) ~[hibernate-validator-8.0.1.Final.jar:8.0.1.Final]
	at org.hibernate.validator.internal.metadata.provider.AnnotationMetaDataProvider.getMetaData(AnnotationMetaDataProvider.java:292) ~[hibernate-validator-8.0.1.Final.jar:8.0.1.Final]
	at org.hibernate.validator.internal.metadata.provider.AnnotationMetaDataProvider.getMethodMetaData(AnnotationMetaDataProvider.java:279) ~[hibernate-validator-8.0.1.Final.jar:8.0.1.Final]
	at org.hibernate.validator.internal.metadata.provider.AnnotationMetaDataProvider.retrieveBeanConfiguration(AnnotationMetaDataProvider.java:131) ~[hibernate-validator-8.0.1.Final.jar:8.0.1.Final]
	at org.hibernate.validator.internal.metadata.provider.AnnotationMetaDataProvider.getBeanConfiguration(AnnotationMetaDataProvider.java:121) ~[hibernate-validator-8.0.1.Final.jar:8.0.1.Final]
	at org.hibernate.validator.internal.metadata.BeanMetaDataManagerImpl.getBeanConfigurationForHierarchy(BeanMetaDataManagerImpl.java:234) ~[hibernate-validator-8.0.1.Final.jar:8.0.1.Final]
	at org.hibernate.validator.internal.metadata.BeanMetaDataManagerImpl.createBeanMetaData(BeanMetaDataManagerImpl.java:201) ~[hibernate-validator-8.0.1.Final.jar:8.0.1.Final]
	at org.hibernate.validator.internal.metadata.BeanMetaDataManagerImpl.getBeanMetaData(BeanMetaDataManagerImpl.java:165) ~[hibernate-validator-8.0.1.Final.jar:8.0.1.Final]
	at org.hibernate.validator.internal.engine.ValidatorImpl.getConstraintsForClass(ValidatorImpl.java:316) ~[hibernate-validator-8.0.1.Final.jar:8.0.1.Final]
	at org.springframework.validation.beanvalidation.BeanValidationBeanRegistrationAotProcessor$BeanValidationDelegate.processAheadOfTime(BeanValidationBeanRegistrationAotProcessor.java:100) ~[spring-context-6.0.11.jar:6.0.11]
	at org.springframework.validation.beanvalidation.BeanValidationBeanRegistrationAotProcessor.processAheadOfTime(BeanValidationBeanRegistrationAotProcessor.java:67) ~[spring-context-6.0.11.jar:6.0.11]
	at org.springframework.beans.factory.aot.BeanDefinitionMethodGeneratorFactory.getAotContributions(BeanDefinitionMethodGeneratorFactory.java:151) ~[spring-beans-6.0.11.jar:6.0.11]
	at org.springframework.beans.factory.aot.BeanDefinitionMethodGeneratorFactory.getBeanDefinitionMethodGenerator(BeanDefinitionMethodGeneratorFactory.java:99) ~[spring-beans-6.0.11.jar:6.0.11]
	at org.springframework.beans.factory.aot.BeanDefinitionMethodGeneratorFactory.getBeanDefinitionMethodGenerator(BeanDefinitionMethodGeneratorFactory.java:115) ~[spring-beans-6.0.11.jar:6.0.11]
	at org.springframework.beans.factory.aot.BeanRegistrationsAotProcessor.processAheadOfTime(BeanRegistrationsAotProcessor.java:49) ~[spring-beans-6.0.11.jar:6.0.11]
	at org.springframework.beans.factory.aot.BeanRegistrationsAotProcessor.processAheadOfTime(BeanRegistrationsAotProcessor.java:37) ~[spring-beans-6.0.11.jar:6.0.11]
	at org.springframework.context.aot.BeanFactoryInitializationAotContributions.getContributions(BeanFactoryInitializationAotContributions.java:67) ~[spring-context-6.0.11.jar:6.0.11]
	at org.springframework.context.aot.BeanFactoryInitializationAotContributions.<init>(BeanFactoryInitializationAotContributions.java:49) ~[spring-context-6.0.11.jar:6.0.11]
	at org.springframework.context.aot.BeanFactoryInitializationAotContributions.<init>(BeanFactoryInitializationAotContributions.java:44) ~[spring-context-6.0.11.jar:6.0.11]
	at org.springframework.context.aot.ApplicationContextAotGenerator.lambda$processAheadOfTime$0(ApplicationContextAotGenerator.java:58) ~[spring-context-6.0.11.jar:6.0.11]
	at org.springframework.context.aot.ApplicationContextAotGenerator.withCglibClassHandler(ApplicationContextAotGenerator.java:67) ~[spring-context-6.0.11.jar:6.0.11]
	at org.springframework.context.aot.ApplicationContextAotGenerator.processAheadOfTime(ApplicationContextAotGenerator.java:53) ~[spring-context-6.0.11.jar:6.0.11]
	at org.springframework.context.aot.ContextAotProcessor.performAotProcessing(ContextAotProcessor.java:106) ~[spring-context-6.0.11.jar:6.0.11]
	at org.springframework.context.aot.ContextAotProcessor.doProcess(ContextAotProcessor.java:84) ~[spring-context-6.0.11.jar:6.0.11]
	at org.springframework.context.aot.ContextAotProcessor.doProcess(ContextAotProcessor.java:49) ~[spring-context-6.0.11.jar:6.0.11]
	at org.springframework.context.aot.AbstractAotProcessor.process(AbstractAotProcessor.java:82) ~[spring-context-6.0.11.jar:6.0.11]
	at org.springframework.boot.SpringApplicationAotProcessor.main(SpringApplicationAotProcessor.java:80) ~[spring-boot-3.1.2.jar:3.1.2]
Caused by: java.lang.ClassNotFoundException: com.querydsl.core.types.Path
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) ~[na:na]
Caused by: java.lang.ClassNotFoundException: com.querydsl.core.types.Path

	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) ~[na:na]
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) ~[na:na]
	at java.base/java.lang.Class.forName0(Native Method) ~[na:na]
	at java.base/java.lang.Class.forName(Class.java:496) ~[na:na]
	at java.base/java.lang.Class.forName(Class.java:475) ~[na:na]
	at java.base/sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(CoreReflectionFactory.java:114) ~[na:na]
	... 39 common frames omitted

i don't use query dsl in project, when gradle native plugin is disabled there is no exception and project runs fine

when i add api 'com.querydsl:querydsl-jpa:5.0.0' as dependency exception is also gone

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Aug 31, 2023
@wilkinsona
Copy link
Member

wilkinsona commented Aug 31, 2023

Does the exception cause AOT processing to fail or is it just distracting and rather noisy? Looking at the message, I suspect it's the latter as it's reporting the reason for "skipping validation constraint hint inference".

@wilkinsona wilkinsona added the status: waiting-for-feedback We need additional information before we can continue label Aug 31, 2023
@adsafawqew
Copy link
Author

it is just distracting, but it was not present in earlier versions

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Aug 31, 2023
@wilkinsona
Copy link
Member

Thanks for the clarification.

I think this could be improved in Spring Framework as most runtime exceptions thrown from getConstraintsForClass will result in an error being logged. In this case, debug logging would be more appropriate as the failure is benign. We'll transfer the issue to the Framework team so that they can consider making such a change.

@bclozel bclozel transferred this issue from spring-projects/spring-boot Aug 31, 2023
@bclozel bclozel changed the title Spring boot, gradle native plugin and query dsl exception Update logging level in BeanValidationBeanRegistrationAotProcessor for validation exceptions Aug 31, 2023
@bclozel bclozel added in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement 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 status: feedback-provided Feedback has been provided labels Aug 31, 2023
@bclozel bclozel added this to the 6.1.x milestone Aug 31, 2023
@sdeleuze sdeleuze self-assigned this Aug 31, 2023
@sdeleuze sdeleuze modified the milestones: 6.1.x, 6.0.12 Aug 31, 2023
@sdeleuze
Copy link
Contributor

@adsafawqew Can you please provide a reproducer? I would like to be able to verify the behavior of the different log levels during AOT processing to refine the logging accordingly.

@sdeleuze sdeleuze added the status: waiting-for-feedback We need additional information before we can continue label Aug 31, 2023
@spring-projects-issues
Copy link
Collaborator

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

@spring-projects-issues spring-projects-issues added the status: feedback-reminder We've sent a reminder that we need additional information before we can continue label Sep 7, 2023
@sdeleuze sdeleuze removed status: waiting-for-feedback We need additional information before we can continue status: feedback-reminder We've sent a reminder that we need additional information before we can continue labels Sep 8, 2023
@zutitziot4324332
Copy link

can confirm that this has been fixed with spring boot version 3.1.4

@ashirmanov
Copy link

having similar issue with spring-boot v 3.1.8 and grralvm gradle plugin v 0.9.28

[2/7] Performing analysis...  [*]                                                                        (8.7s @ 1.27GB)
   7,970 (85.10%) of  9,365 classes reachable
   9,846 (63.42%) of 15,524 fields reachable
  26,676 (73.17%) of 36,459 methods reachable
   1,337 classes, 1,524 fields, and 2,538 methods registered for reflection
       1 native library: -framework CoreServices

Fatal error: java.lang.TypeNotPresentException: Type com.querydsl.core.types.Path not present
        at java.base/sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(CoreReflectionFactory.java:117)
        at java.base/sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:125)
        at java.base/sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49)
        at java.base/sun.reflect.generics.visitor.Reifier.reifyTypeArguments(Reifier.java:68)
        at java.base/sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:138)
        at java.base/sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49)
        at java.base/sun.reflect.generics.repository.MethodRepository.computeReturnType(MethodRepository.java:75)
        at java.base/sun.reflect.generics.repository.MethodRepository.getReturnType(MethodRepository.java:66)
        at java.base/java.lang.reflect.Method.getGenericReturnType(Method.java:295)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.reflect.ReflectionDataBuilder.registerTypesForMethod(ReflectionDataBuilder.java:505)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.reflect.ReflectionDataBuilder.processMethodMetadata(ReflectionDataBuilder.java:264)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.reflect.ReflectionDataBuilder.duringAnalysis(ReflectionDataBuilder.java:199)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.reflect.ReflectionFeature.duringAnalysis(ReflectionFeature.java:254)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.lambda$runPointsToAnalysis$10(NativeImageGenerator.java:748)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.FeatureHandler.forEachFeature(FeatureHandler.java:85)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.lambda$runPointsToAnalysis$11(NativeImageGenerator.java:748)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.AbstractAnalysisEngine.runAnalysis(AbstractAnalysisEngine.java:162)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.runPointsToAnalysis(NativeImageGenerator.java:745)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:578)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.run(NativeImageGenerator.java:535)
------------------------------------------------------------------------------------------------------------------------
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.buildImage(NativeImageGeneratorRunner.java:403)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.build(NativeImageGeneratorRunner.java:580)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.main(NativeImageGeneratorRunner.java:128)
Caused by: java.lang.ClassNotFoundException: com.querydsl.core.types.Path
        at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:445)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:587)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
        at java.base/java.lang.Class.forName0(Native Method)
        at java.base/java.lang.Class.forName(Class.java:467)
        at java.base/sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(CoreReflectionFactory.java:114)
        ... 22 more
                        3.6s (7.5% of total time) in 27 GCs | Peak RSS: 4.60GB | CPU load: 2.69

also have no querydsl usage in my project so wonder if this is something given by Spring's transitive dependencies and/or an issue in gradle plugin itself.

@sdeleuze
Copy link
Contributor

@ashirmanov Please create a new issue with a reproducer as an attached archive or a link to a repository if you want us to have a look.

@NHRAdmin
Copy link

NHRAdmin commented Apr 3, 2024

Had the same issue building native image with graalVM @ashirmanov , resolved by adding: implementation 'com.querydsl:querydsl-core:5.1.0' to my build.gradle. I honestly don't know what is using it under the hood, but the latest dependency I added was org.springdoc:springdoc-openapi-starter-webmvc-ui:2.4.0.

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: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

8 participants