Generated proxy must be defined in super class loader (IllegalAccessError if it is not in the same class loader ), TCL must be OK too becouse TCL == persistentClass.getClassLoader() in any deployment (it must be true for j2ee, but I am not sure about eclipse stuff, some container like IDE can break TCL ). Callback and dependant stuff (including cglib core classes) are loaded using same class loader, so cglib and ASM must be in the same or in the parent class loader (it is OK for both deployment types too, TCL is child of shared class loader). In short we can not change class loader for proxies, super class loader is the correct class loader for all use cases.
--- Max Rydahl Andersen <[EMAIL PROTECTED]> wrote: > > logging is the least of our problems if we get a > "third" classloader. > > e.g. which classloader should be used to load > callback code ? > > I would say TCL first *always*, but if the bytecode > generated stuff > is placed in a third possibly completly seperated > classloader calling > the callback can result in extremely weird errors - > they will need to > have the same parent anyways to have compatible > classes...hence TCL. > > Or is there something I'm missing here ? > > /max > > > > > It is popular to use static "log" field, this > field is > > shared by all contexts in shared deployment but > first > > loaded context will be used to configure logger or > > "warn,indo,debug, ..." must be wrapped to cache > and to > > select "current configuration" using context > loader on > > every call (probably commons logging doe's it, but > it > > looks bit expensive for logging). So library must > be > > designed in very special way for this use case. > > Probably there is no good common way and > > parametrization or ClassLoader injection can help. > > > > --- Max Rydahl Andersen <[EMAIL PROTECTED]> > > wrote: > > > >> On Thu, 02 Feb 2006 22:00:39 +0100, Scott M Stark > >> <[EMAIL PROTECTED]> > >> wrote: > >> > >> > Because the there may be serveral class loaders > >> associated with a > >> > deployment. I'm missing the exact context of > this > >> discussion and how it > >> > correlates with the entity manager spi. Has > there > >> been a definition of > >> > what the tcl must be for the entity manager spi > >> lifecycle? I don't see > >> > it browsing through the current ejb3 spec. > >> > >> the problem is that if it is really necessary to > >> have a *third* external > >> classloader > >> which is neither available via someclass.forName > nor > >> TCL then we need to > >> carry this classloader around and pass it on to > hard > >> to reach places. > >> > >> /max > >> > >> > > >> > -----Original Message----- > >> > From: Max Andersen > >> > Sent: Thursday, February 02, 2006 3:09 PM > >> > To: Scott M Stark; Emmanuel Bernard; Bill Burke > >> > Cc: Hibernate development > >> > Subject: Re: [Hibernate] ClassLoader injection > >> > > >> > hi, > >> > > >> > Why is the tcl not the right one even when > >> generating classes ? > >> > > >> > if we don't use the same how can you have > >> consistent resource loading, > >> > annotation searching and code invocation ? > >> > > >> > /max > >> > > >> >> The general problem is that the thread context > >> class loader can be too > >> >> generic when you have a mesh of class loaders. > As > >> is mentioned in > >> > latter > >> >> replies in this thread, if classes from a > given > >> package namespace have > >> >> already been loaded via one class loader, > >> generally all subsequent > >> >> classes in the same package should be > >> loaded/defined using the same > >> >> class loader. Not doing so will lead to > security > >> and type consistency > >> >> problems. > >> >> > >> >> In the case of the ejb3 entity manager spi, it > >> does make sense that > >> > you > >> >> would ask it for the correct class loader for > >> byte code manipulation > >> > vs > >> >> a class loader to query for resources and do > >> annotation searching. > >> >> > >> >> -----Original Message----- > >> >> From: Max Andersen > >> >> Sent: Tuesday, January 31, 2006 11:53 PM > >> >> To: Emmanuel Bernard; Bill Burke > >> >> Cc: Hibernate development; Scott M Stark > >> >> Subject: Re: [Hibernate] ClassLoader injection > >> >> > >> >> Hi, > >> >> > >> >> to bill, yes I know ctx current thread is the > >> only way, that was my > >> >> whole > >> >> point (using ctx current thread in > >> >> hibernate was actually the first patch i > provided > >> to hibernate core ;) > >> >> > >> >> and yes, having a third classloader concept in > >> the spec sounds like a > >> >> very > >> >> broken thing. > >> >> I would love to hear why it is needed. > >> >> > >> >> /max > >> >> > >> >>> The RI team is going to creak, but I'm > inclined > >> to remove it as well. > >> >>> > >> >>> AS for your first remark, what's wrong with > >> doing getResource with > >> > the > >> >> > >> >>> regular classloader? I don't get it. > >> >>> > >> >>> > >> >>> Bill Burke wrote: > >> >>>> I understand the need for > >> PUInfo.getNewTempClassLoader() as > >> >>>> getResource("META-INF/persistence.xml") > >> may/will return multiples. > >> >>>> Also, you may want to introspect the class > for > >> annotations before > >> > you > >> >> > >> >>>> decide what needs to be bytecode massaged. > >> >>>> > >> >>>> As for getClassLoader()? I'm not sure of > the > >> reasoning. I know > >> >> Scott > >> >>>> has some spec input on this. Maybe we > should > >> get it removed? > >> >>>> > >> >>>> Emmanuel Bernard wrote: > >> >>>>> Year I'm aware of that Bill :-) > >> >>>>> But in this case, and like Max said, why on > >> earth the > >> >>>>> PersistenceUnitInfo has a getClassLoader() > >> method instead of using > >> >> the > >> >>>>> context CL? > >> >>>>> > >> >>>>> > >> >>>>> Bill Burke wrote: > >> >>>>> > >> >>>>>> > >> >>>>>> > >> >>>>>> Max Rydahl Andersen wrote: > >> >>>>>> > >> >>>>>>> If it is for the spec then I would argue > >> that the spec is very > >> >> wrong > >> >>>>>>> since it will > >> >>>>>>> break all other kind of stuff. Like how > will > >> you convince all the > >> >> > >> >>>>>>> external libraries hibernate > >> >>>>>>> uses to use your "magic" classloader ? > (e.g. > >> log4j, dom4j, cglib, > >> >> > >> >>>>>>> yada, yada) > === message truncated === __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com ------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642 _______________________________________________ hibernate-devel mailing list hibernate-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/hibernate-devel