[hibernate-issues] [Hibernate-JIRA] Commented: (HV-562) Incorrect use of TCL to check visibility to JPA classes

Hardy Ferentschik (JIRA) noreply at atlassian.com
Wed Apr 25 08:09:49 EDT 2012


    [ https://hibernate.onjira.com/browse/HV-562?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=46415#comment-46415 ] 

Hardy Ferentschik commented on HV-562:
--------------------------------------

_javax.persistence.Persistence_ is not part of the Validator package, hence we stick to the approach of TCL first, then _Class#forName_.

> 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: 
> {code}
> private void detectJPA() {
> 		try {
> 			loadClass( PERSISTENCE_UTIL_CLASS_NAME, this.getClass() );
> 			log.debug( "Found {} on classpath.", PERSISTENCE_UTIL_CLASS_NAME );
> 		}
> {code}
> _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

        


More information about the hibernate-issues mailing list