You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you run an AOT test in spring-web it gathers the contributors available on the classpath, which includes BeanValidationBeanRegistrationAotProcessor. At the moment this fails with:
java.lang.NoSuchMethodError: 'java.lang.Object org.jboss.logging.Logger.getMessageLogger(java.lang.invoke.MethodHandles$Lookup, java.lang.Class, java.lang.String)'
at org.hibernate.validator.internal.util.logging.LoggerFactory.make(LoggerFactory.java:21)
at org.hibernate.validator.internal.util.Version.<clinit>(Version.java:18)
at org.hibernate.validator.internal.engine.AbstractConfigurationImpl.<clinit>(AbstractConfigurationImpl.java:80)
at org.hibernate.validator.HibernateValidator.createGenericConfiguration(HibernateValidator.java:31)
at jakarta.validation.Validation$GenericBootstrapImpl.configure(Validation.java:296)
at jakarta.validation.Validation.buildDefaultValidatorFactory(Validation.java:103)
at org.springframework.validation.beanvalidation.BeanValidationBeanRegistrationAotProcessor$BeanValidationDelegate.getValidatorIfAvailable(BeanValidationBeanRegistrationAotProcessor.java:88)
at org.springframework.validation.beanvalidation.BeanValidationBeanRegistrationAotProcessor$BeanValidationDelegate.<clinit>(BeanValidationBeanRegistrationAotProcessor.java:85)
at org.springframework.validation.beanvalidation.BeanValidationBeanRegistrationAotProcessor.processAheadOfTime(BeanValidationBeanRegistrationAotProcessor.java:74)
at org.springframework.beans.factory.aot.BeanDefinitionMethodGeneratorFactory.getAotContributions(BeanDefinitionMethodGeneratorFactory.java:153)
at org.springframework.beans.factory.aot.BeanDefinitionMethodGeneratorFactory.getBeanDefinitionMethodGenerator(BeanDefinitionMethodGeneratorFactory.java:98)
at org.springframework.beans.factory.aot.BeanDefinitionMethodGeneratorFactory.getBeanDefinitionMethodGenerator(BeanDefinitionMethodGeneratorFactory.java:113)
at org.springframework.beans.factory.aot.BeanRegistrationsAotProcessor.processAheadOfTime(BeanRegistrationsAotProcessor.java:49)
at org.springframework.beans.factory.aot.BeanRegistrationsAotProcessor.processAheadOfTime(BeanRegistrationsAotProcessor.java:38)
at org.springframework.context.aot.BeanFactoryInitializationAotContributions.processAheadOfTime(BeanFactoryInitializationAotContributions.java:82)
at org.springframework.context.aot.BeanFactoryInitializationAotContributions.getContributions(BeanFactoryInitializationAotContributions.java:70)
at org.springframework.context.aot.BeanFactoryInitializationAotContributions.<init>(BeanFactoryInitializationAotContributions.java:53)
at org.springframework.context.aot.BeanFactoryInitializationAotContributions.<init>(BeanFactoryInitializationAotContributions.java:48)
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.web.service.registry.AnnotationHttpServiceRegistrarTests.compile(AnnotationHttpServiceRegistrarTests.java:102)
at org.springframework.web.service.registry.AnnotationHttpServiceRegistrarTests.basicListingWithAot(AnnotationHttpServiceRegistrarTests.java:69)
at java.base/java.lang.reflect.Method.invoke(Method.java:565)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1604)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1604)
spring-web uses JBoss logging 3.4.3.Final, but the above method does not exist. I can see the framework build also uses a mixture of versions since the jboss logging version isn't managed by the build.
Given that this contributor checks if the validator is available at all, perhaps an extra catch in
sbrannen
changed the title
Guard NoSuchMethodError from BeanValidationBeanRegistrationAotProcessor
Guard against NoSuchMethodError in BeanValidationBeanRegistrationAotProcessor
Apr 14, 2025
Since we are not trying to cover test scenarios with mixed classpaths but rather production scenarios which should have clean classpaths, I'd take the presence of Hibernate Validator itself as requiring a corresponding JBoss Logging version underneath. If we get this wrong ourselves somewhere, we should update the JBoss Logging version.
Wherever we happen to encounter it at runtime, we could try to throw a more meaningful exception along the lines of "Hibernate Validator classpath mismatch: make sure that your Hibernate Validator setup has all of its transitive dependencies present in the correct version". I'd much prefer that over silently swallowing such a mismatch.
snicoll
changed the title
Guard against NoSuchMethodError in BeanValidationBeanRegistrationAotProcessor
Add dependency management for 'org.jboss.logging:jboss-logging'
Apr 14, 2025
If you run an AOT test in
spring-web
it gathers the contributors available on the classpath, which includesBeanValidationBeanRegistrationAotProcessor
. At the moment this fails with:spring-web
uses JBoss logging3.4.3.Final
, but the above method does not exist. I can see the framework build also uses a mixture of versions since the jboss logging version isn't managed by the build.Given that this contributor checks if the validator is available at all, perhaps an extra catch in
spring-framework/spring-context/src/main/java/org/springframework/validation/beanvalidation/BeanValidationBeanRegistrationAotProcessor.java
Line 90 in 6ade8c5
The text was updated successfully, but these errors were encountered: