Skip to content

Add dependency management for 'org.jboss.logging:jboss-logging' #34749

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

Closed
snicoll opened this issue Apr 13, 2025 · 2 comments
Closed

Add dependency management for 'org.jboss.logging:jboss-logging' #34749

snicoll opened this issue Apr 13, 2025 · 2 comments
Assignees
Labels
type: task A general task
Milestone

Comments

@snicoll
Copy link
Member

snicoll commented Apr 13, 2025

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

could be interesting? It fixed my problem.

@snicoll snicoll added the status: waiting-for-triage An issue we've not yet triaged or decided on label Apr 13, 2025
snicoll added a commit to snicoll/spring-framework that referenced this issue Apr 14, 2025
@sbrannen sbrannen added in: web Issues in web modules (web, webmvc, webflux, websocket) theme: aot An issue related to Ahead-of-time processing labels Apr 14, 2025
@sbrannen sbrannen changed the title Guard NoSuchMethodError from BeanValidationBeanRegistrationAotProcessor Guard against NoSuchMethodError in BeanValidationBeanRegistrationAotProcessor Apr 14, 2025
@jhoeller
Copy link
Contributor

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 snicoll removed the theme: aot An issue related to Ahead-of-time processing label Apr 14, 2025
@snicoll snicoll changed the title Guard against NoSuchMethodError in BeanValidationBeanRegistrationAotProcessor Add dependency management for 'org.jboss.logging:jboss-logging' Apr 14, 2025
@snicoll snicoll added type: task A general task and removed status: waiting-for-triage An issue we've not yet triaged or decided on in: web Issues in web modules (web, webmvc, webflux, websocket) labels Apr 14, 2025
@snicoll snicoll self-assigned this Apr 14, 2025
@snicoll snicoll added this to the 7.0.0-M4 milestone Apr 14, 2025
@snicoll
Copy link
Member Author

snicoll commented Apr 14, 2025

Yeah, I admittedly was a bit too quick to reach a conclusion here. It's rather the build that needs fixing. I've repurposed this issue to that effect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: task A general task
Projects
None yet
Development

No branches or pull requests

3 participants