Skip to content

Illegal reflection use on Hibernate Validator 9 #36012

@johchur

Description

@johchur

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 [email protected]/org.springframework.validation.beanvalidation.LocalValidatorFactoryBean.afterPropertiesSet(LocalValidatorFactoryBean.java:267)
        at [email protected]/org.springframework.boot.context.properties.ConfigurationPropertiesJsr303Validator$Delegate.<init>(ConfigurationPropertiesJsr303Validator.java:72)
        at [email protected]/org.springframework.boot.context.properties.ConfigurationPropertiesJsr303Validator.<init>(ConfigurationPropertiesJsr303Validator.java:43)
        at [email protected]/org.springframework.boot.context.properties.ConfigurationPropertiesBinder.getJsr303Validator(ConfigurationPropertiesBinder.java:182)
        at [email protected]/org.springframework.boot.context.properties.ConfigurationPropertiesBinder.getValidators(ConfigurationPropertiesBinder.java:160)
        at [email protected]/org.springframework.boot.context.properties.ConfigurationPropertiesBinder.getBindHandler(ConfigurationPropertiesBinder.java:114)
        at [email protected]/org.springframework.boot.context.properties.ConfigurationPropertiesBinder.bind(ConfigurationPropertiesBinder.java:95)
        at [email protected]/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

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: dataIssues in data modules (jdbc, orm, oxm, tx)status: waiting-for-triageAn issue we've not yet triaged or decided on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions