Greater flexibility in configuring your web application's class path

Greater flexibility in configuring your web application's class path

Greater flexibility in configuring your web application's class path

If you've ever had to augment your web application's classpath in the past, you're probably familiar with the extra-class-path attribute of the class-loader element in sun-web.xml.

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/lib and 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/lib/extra/extra.jar and 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>
Comments:

[Trackback] GlassFish v2 beta (called Milestone4) is out! Come to learn what's new for the Web Container.

Posted by Jean-Francois Arcand's Blog on January 24, 2007 at 11:57 PM PST #

Hi Jan,
Can extra-class-path be used to refer to a jar from a different webapp?. For example..i have two webapps W1 and W2. A class in W2 refers to a class in a JAR(J1) in W1. Can i add the following in W2's sun-web.xml
<class-loader extra-class-path="../W1/WEB-INF/lib/J1.jar"/>

Thanks,
Deepak

Posted by Deepak Gothe on March 22, 2009 at 04:19 PM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed
About

jluehe

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today