users@glassfish.java.net

Re: delegate="true" or delegate="false"

From: Jan Luehe <Jan.Luehe_at_Sun.COM>
Date: Mon, 14 Dec 2009 18:36:17 -0800

On 12/12/09 02:45, glassfish_at_javadesktop.org wrote:
> Hi all,
>
> I have read almost all post in forums and web, I have still problems about delegation model of my EAR application which is consisting WEB and EJB module. My web module is also consisting restful web services.
>
> I have read necessary documenations and it says:
>
>
> [b]
> The Java Servlet speciication recommends that a webmodule's class loader look in the local class loader before delegating to its parent. You canmake this class loader follow the delegation inversion model in the Servlet speciication by setting delegate="false" in the class-loader element of the sun-web.xml ile. It is safe to do this only for a webmodule that does not interact with any other modules. For details, see “class-loader” in Sun GlassFish Enterprise Server v3 Application Deployment Guide.
>
> The default value is delegate="true", which causes a webmodule's class loader to delegate in the samemanner as the other class loaders. Youmust use delegate="true" for a web application that accesses EJB components or that acts as a web service client or endpoint. For details about sun-web.xml, see Sun GlassFish Enterprise Server v3 Application Deployment Guide.
> [/b]
>
>
> Shortly, I want to use always my bundled libraries in my modules without regard to be included in my application server. If my modules had this library, they should be loaded from my application.
>
>
> 1 - ) For example, Glassfish V3 is bundled with Jersey 1.1.4.1. If my modules need to use 1.1.5-ea-SNAPSHOT what my delegation value in my sun-web.xml should be ? (Both of my modules need to use 1.1.5-ea-SNAPHOT)
>
>
> 2 - ) As far as I know, the packages javax.* are not loaded with this delegation model. If I want to use new version of these libraries, what should I do? For example JSR-303 libraries is good example of it. I want to use new snaphots of Hibernate Validater which has javax.validation.* packages. I am not sure in this case what will happen.
>
>
> 3 - ) What is the motivation behind this setting which is default false. I think that it should be default false. Because If an application has a library, it means that it delibrately consisting it. That is to say, it should be loaded.
>
> 4 - ) Again from my understandings, this setting is just for web modules. What is the equalivant setting in EJB Modules.
>

There are a number of packages, including "java.*" and "javax.*",
for which symbol resolution will always be delegated to the parent
classloader,
regardless of the WebappClassLoader's "delegate" setting.

This is to ensure that applications are prevented from overriding core
Java runtime
classes or changing the API versions of specifications that are part of
the Java EE
platform.

The only exception to the "unconditional delegation" rule is related to the
"useBundledJsf" configuration option (also in sun-web.xml), which allows
a web application to have a bundled "javax.faces.*" (in addition to
"com.sun.faces.*") honored.

See Arun Gupta's blog at
http://weblogs.java.net/blog/2008/12/11/totd-59-alternative-jsf-implementations-glassfish-myfaces-and-tomahawk
for additional info.

As far as I know, the WebappClassloader is the only type of classloader in
GlassFish whose delegation behaviour is configurable.

Jan

> [Message sent by forum member 'sessizlik' ]
>
> http://forums.java.net/jive/thread.jspa?messageID=376145
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>