Greater flexibility in configuring your web application's class path
By jluehe on Aug 11, 2006
Greater flexibility in configuring your web application's class pathIf you've ever had to augment your web application's classpath in the past, you're probably familiar with the
extra-class-pathattribute of the
For those who aren't: This attribute takes a colon or semi-colon separated list of paths that are added to the list of repositories that your web application's classloader will consider when asked to load a particular resource (by default, a web application's classloader is required to consider only resources located in the
WEB-INF/classes directories of a web application).
The documentation of the
extra-class-path attribute has failed to specify how relative paths listed in this attribute's value are to be resolved. Up until recently, GlassFish has interpreted relative paths as relative to the application server's current directory, which is set to your domain's
$INSTANCE_ROOT/config during startup. For example, a path of the form
WEB-INF/lib/extra/extra.jar used to be resolved to
$INSTANCE_ROOT/config/WEB-INF/lib/extra/extra.jar. Not very useful!
As of GlassFish Promoted Build v2 12, we've changed the interpretation of any relative paths listed in
the value of the
extra-class-path attribute so they are resolved relative to a web application's context root, which will serve developers' needs much better.
For example, if you want your web application's classloader to also consider resources in
WEB-INF/extra-classes bundled with your web application, you specify the
extra-class-path attribute in your web application's
sun-web.xml, as follows:
<sun-web-app> <class-loader extra-class-path="WEB-INF/lib/extra/extra.jar:WEB-INF/extra-classes"/> </sun-web-app>