When a class is requested (either implicitly through a class reference or explicitly with class.forName
), the ClassLoader
of the calling Class
is used. This allows an Applet
or an RMI-based application to refer to other classes that have been acquired from a remote site and ensure that they are downloaded from the same location as well.
However, libraries loaded from one ClassLoader
cannot necessarily see classes loaded from another ClassLoader
.
This often occurs with Object Relational Mapping (ORM) tools such as Hibernate that use configuration files that contain class names. To load the classes, it needs to resolve class names from the application's associated ClassLoader
.
If the Hibernate library is installed in the same WAR as the webapp, this will be automatic. However, if Hibernate is stored in the webapp server's global classpath or an extension location, then it won't have visibility to the webapp's ClassLoader
.
To solve this (specifically for the benefit of...