| I have Spring Boot (1.5.7.RELEASE) web application, which contains spring-boot-starter-web dependency, which transitively pulls in org.hibernate:hibernate-validator:5.3.5.Final I have Spring MVC mapping
public ... processEvent(@Valid @RequestBody UpstreamEvent event) {}
When the application is deployed to Tomcat, validation works. When the application is deployed to Weblogic, the application throws ClassCastException When the web request comes in, the input gets validated by Validator and uses hibernate validator (HV) to get the job done. HV calls
Persistence.getPersistenceUtil().isLoaded( traversableObject, traversableProperty.getName() );
in
JPATraversableResolver.isReachable
Then
Persistence.getProviders();
is called, whereas in Tomcat there is only 1 Hibernate provider, in weblogic there are 4 (hibernate one kept atop):
- org.hibernate.jpa.HibernatePersistenceProvider
- org.eclipse.persistence.jpa.PersistenceProvider
- org.apache.openjpa.persistence.PersistenceProviderImpl
- kodo.persistence.PersistenceProviderImpl
Code in Persistence#PersistenceUtil
new PersistenceUtil() {
public boolean isLoaded(Object entity, String attributeName) {
List<PersistenceProvider> providers = Persistence.getProviders();
for ( PersistenceProvider provider : providers ) {
final LoadState state = provider.getProviderUtil().isLoadedWithoutReference( entity, attributeName );
if ( state == LoadState.UNKNOWN ) continue;
return state == LoadState.LOADED;
}
for ( PersistenceProvider provider : providers ) {
final LoadState state = provider.getProviderUtil().isLoadedWithReference( entity, attributeName );
if ( state == LoadState.UNKNOWN ) continue;
return state == LoadState.LOADED;
}
return true;
}
tries to iterate through all providers, but second one blows up with exceptions:
|