Incorrect use of TCL to check visibility to JPA classes
-------------------------------------------------------
Key: HV-562
URL:
https://hibernate.onjira.com/browse/HV-562
Project: Hibernate Validator
Issue Type: Bug
Components: engine
Affects Versions: 4.1.0.Final
Reporter: Sanjeeb Sahoo
Priority: Critical
org.hibernate.validator.engine.resolver.DefaultTraversableResolver uses Thread's
context class loader to check existence of PERSISTENCE_UTIL_CLASS_NAME as shown in the
code below:
The following code
private void detectJPA() {
try {
loadClass( PERSISTENCE_UTIL_CLASS_NAME, this.getClass() );
log.debug( "Found {} on classpath.", PERSISTENCE_UTIL_CLASS_NAME );
}
loadClass() first tries to use TCL to load the class. If TCL can't load, then it uses
the class loader of the second argument to load the class. This is incorrect. It does not
matter whether TCL can load PERSISTENCE_UTIL_CLASS_NAME, what matters is whether the class
loader which is going to be used to load JPA_AWARE_TRAVERSABLE_RESOLVER_CLASS_NAME can
load PERSISTENCE_UTIL_CLASS_NAME or not. Since HV-363 has now been fixed to use current
class loader to load JPA_AWARE_TRAVERSABLE_RESOLVER_CLASS_NAME, the same class loader
should also be used to detect existence of PERSISTENCE_UTIL_CLASS_NAME.
--
This message is automatically generated by JIRA.
For more information on JIRA, see:
http://www.atlassian.com/software/jira