users@glassfish.java.net

RE: Can someone explain delegate="true"?

From: Martin Gainty <mgainty_at_hotmail.com>
Date: Wed, 13 May 2009 16:17:13 -0400

this is a restate of previously published doc available at
http://docs.sun.com/app/docs/doc/820-4336/beade?a=view
Delegation


Note that the class loader hierarchy is not a Java inheritance
hierarchy, but a delegation hierarchy. In the delegation design, a
class loader delegates classloading to its parent before attempting
to load a class itself. A class loader parent can be either the System
class loader or another custom class loader. If the parent class loader
cannot load a class, the class loader attempts to load the class itself.
In effect, a class loader is responsible for loading only the classes
not available to the parent. Classes loaded by a class loader higher
in the hierarchy cannot refer to classes available lower in the hierarchy.



The Java Servlet specification
recommends that the Web class loader look in the local class loader
before delegating to its parent. You can make the Web class loader
follow the delegation inversion model in the Servlet specification
by setting delegate="false" in the class-loader element of the sun-web.xml file. It is safe to do this only for a web module
that does not interact with any other modules. For details, see class-loader in Sun GlassFish Enterprise Server 2.1 Application Deployment Guide.


The default value is delegate="true", which
causes the Web class loader to delegate in the same manner as the
other class loaders. You must 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 2.1 Application Deployment Guide

In short webapp cl has no knowledge of system defined component classes until you instruct WebApp classloader to load from parent via delegate="true"

I hope that answers your question
Martin Gainty
______________________________________________
Disclaimer and Confidentiality/Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
This message is confidential. If you should not be the intended receiver, then we ask politely to report. Each unauthorized forwarding or manufacturing of a copy is inadmissible. This message serves only for the exchange of information and has no legal binding effect. Due to the easy manipulation of emails we cannot take responsibility over the the contents.
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.




> Date: Wed, 13 May 2009 12:43:16 -0700
> From: glassfish_at_javadesktop.org
> To: users_at_glassfish.dev.java.net
> Subject: Can someone explain delegate="true"?
>
> Hi all,
>
> From the documentation (delegate="true")
>
> (optional) If true, the web module follows the standard class loader delegation model and delegates to its parent class loader first before looking in the local class loader. You must set this to true for a web application that accesses EJB components or that acts as a web service client or endpoint.
>
> Can someone explain why delegate needs to be true to:
>
> 1. accesses an EJB component.
> 2. act as a web service client.
> 3. act as a web service endpoint.
>
> Thanks!
> [Message sent by forum member 'mriem' (mriem)]
>
> http://forums.java.net/jive/thread.jspa?messageID=346148
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>

_________________________________________________________________
Windows Live™: Keep your life in sync.
http://windowslive.com/explore?ocid=TXT_TAGLM_BR_life_in_synch_052009