spring-boot: Bean Validation is incorrectly identified as being present on WLP due to a partial leak of its API into the app's class loader
Spring boot 1.5.8. Liberty version:
/opt/Liberty/bin/productInfo version
Product name: WebSphere Application Server
Product version: 17.0.0.2
Product edition: LIBERTY_CORE
I have problems booting on Liberty
WARN org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'methodValidationPostProcessor' defined in class path resource [org/springframework/boot/autoconfigure/validation/ValidationAutoConfiguration.class]: Unsatisfied dependency expressed through method 'methodValidationPostProcessor' parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultValidator' defined in class path resource [org/springframework/boot/autoconfigure/validation/DefaultValidatorConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.validation.beanvalidation.LocalValidatorFactoryBean]: Factory method 'defaultValidator' threw exception; nested exception is java.lang.LinkageError: loading constraint violation when resolving method "javax/validation/Validation.byDefaultProvider()Ljavax/validation/bootstrap/GenericBootstrap;" : loader "com/ibm/ws/classloading/internal/AppClassLoader@a3fad3f0" of class "org/springframework/boot/validation/MessageInterpolatorFactory" and loader "org/eclipse/osgi/internal/loader/EquinoxClassLoader@65505351" of class "javax/validation/Validation" have different types for the method signature
My war contents (alongside other stuff):
unzip -t dropins/myapp.war |grep -i val
testing: WEB-INF/lib/validation-api-1.1.0.Final.jar OK
testing: WEB-INF/lib/hibernate-validator-5.4.1.Final.jar OK
There seems to be other with the same problem: https://www.cpume.com/question/fhfsooff-spring-boot-jpa-applicationeventmulticaster-not-initialized-issue.html
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 16 (16 by maintainers)
With some help from the WLP team, the problem’s been tracked down to the cdi-1.2 feature leaking a subset of the Bean Validation 1.1 API’s packages into the app’s class loader. This causes
ConfigurationPropertiesBindingPostProcessor
to assume that all of the Bean Validation API is available when, in fact, classes injavax.validation.bootstrap
are not available. This is particularly nasty as classes injavax.validation
return instances of classes injavax.validation.bootstrap
. This really needs to be fixed in WLP but, in the meantime, we can probably look for a class injavax.validation.bootstrap
as well.