There is no new information here. Obviously the difference is moving from Class.forName to ClassLoaderService.classForName. The question is why that causes the difference. Both load classes.
* ClassLoaderService.classForName resolves to ClassLoader.loadClass on the numerous ClassLoaders known to Hibernate.
* CLass.forName resolves to an attempt to load the class from just a single ClassLoader. Here it uses the ClassLoadder of the Hibernate classes.
The JDBC 4 version of DriverManager (Java 6 and up) has some code now to check the the ClassLoader of the Driver against the ClassLoader of the calling class (Hibernate). Pretty sure thats all new as part of the JDBC move to service loading. My suspicion is that this is the underlying cause of the problem. Please debug through DriverManager.getConnection(String url, java.util.Properties info, ClassLoader callerCL) method. Specifically look for the code block that looks like:
Code:
// If the caller does not have permission to load the driver then
// skip it.
if ( getCallerClass(callerCL, di.driverClassName ) != di.driverClass ) {
println(" skipping: " + di);
continue;
}
I am assuming this is where it breaks down. Calling Class.forName forces the ClassLoader to be the same as when DriverManager.getConnection is called since both explicitly use the "caller ClassLoader".
Since 4.0 Hibernate requires Java 6, which in turn means JDBC 4.