With Version 9 Hibernate Validator introduced a module-info file hiding the internal-packages (https://github.com/hibernate/hibernate-validator/blob/main/engine/pom.xml#L400-L402). During application startup the class LocalValidatorFactoryBean calls the method externalClassLoader of the interface HibernateValidatorConfiguration via reflection. This is no longer possible on module-path aware applications since the implementation of the method is located in class org.hibernate.validator.internal.engine.AbstractConfigurationImpl.

Stacktrace:

java.lang.IllegalStateException: Could not access method or field: class org.springframework.util.ReflectionUtils cannot access class org.hibernate.validator.internal.engine.AbstractConfigurationImpl (in module org.hibernate.validator) because module org.hibernate.validator does not export org.hibernate.validator.internal.engine to unnamed module @7357a011
        at org.springframework.util.ReflectionUtils.handleReflectionException(ReflectionUtils.java:109)
        at org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:284)
        at spring.context@7.0.1/org.springframework.validation.beanvalidation.LocalValidatorFactoryBean.afterPropertiesSet(LocalValidatorFactoryBean.java:267)
        at spring.boot@4.0.0/org.springframework.boot.context.properties.ConfigurationPropertiesJsr303Validator$Delegate.<init>(ConfigurationPropertiesJsr303Validator.java:72)
        at spring.boot@4.0.0/org.springframework.boot.context.properties.ConfigurationPropertiesJsr303Validator.<init>(ConfigurationPropertiesJsr303Validator.java:43)
        at spring.boot@4.0.0/org.springframework.boot.context.properties.ConfigurationPropertiesBinder.getJsr303Validator(ConfigurationPropertiesBinder.java:182)
        at spring.boot@4.0.0/org.springframework.boot.context.properties.ConfigurationPropertiesBinder.getValidators(ConfigurationPropertiesBinder.java:160)
        at spring.boot@4.0.0/org.springframework.boot.context.properties.ConfigurationPropertiesBinder.getBindHandler(ConfigurationPropertiesBinder.java:114)
        at spring.boot@4.0.0/org.springframework.boot.context.properties.ConfigurationPropertiesBinder.bind(ConfigurationPropertiesBinder.java:95)
        at spring.boot@4.0.0/org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.bind(ConfigurationPropertiesBindingPostProcessor.java:101)
        ... 47 more

A simple reproducer project is attached. The application starts successfully, if Hibernate Validator 8 is used instead of the new one.

validator-demo.zip

Comment From: jhoeller

Thanks for the report!

Like in other places, we enforce a publicly accessible method for externalClassLoader(ClassLoader) - in this case, it should find the corresponding method in the BaseHibernateValidatorConfiguration interface - before attempting reflection now.

This is available in the latest Spring Framework 7.0.3 snapshot already. Please give it an early try!