--- Max Rydahl Andersen <[EMAIL PROTECTED]> wrote:
> > > > I do not think it is possible to find the the best > way > > for this stuff, but we expected hibernate (and > cglib) > > classes will be in the same or in the parent > > classloader (asumption is based on j2ee container > > class loading stuff). It must be better to use > this > > asumption, it has more chances to be maintained. > > Well, unfortunately not. > > Our classloading should try to do as ReflectHelper > does. > > look in ctxthread first and then in the class own > classloader. Yes, it is the right way on container ( container will set the right classloader it will be the same as we need ) > > that is the right way to do it in J2EE, not the > other way around. Proxy classloader doe's not conflict with ReflectHelper for very simple reason, it uses domain class loader (domain class is loaded by ReflectHelper). Proxy is defined in the same classloader as domain class. This classloader can be from any context, but it must be the same as application classloader. Package visibility domain classes and mebers can not work in the other way (IllegalAccessError). Cglib and hibernate interfaces are public and this stuff can be in the same or in the parent class loader. > > As I understand it cglib in this case only look in > its own classloader. Class loader is a parameter in cglib, default is a super class loader (it is the right class loader for public and for package visibility classes) > > -max > > > --- "Ivan S. Dubrov" <[EMAIL PROTECTED]> wrote: > > > >> > > >> >cant see your attachement (at netcafe ,), but im > >> quite sure this is not the right solution to this > >> *eclipse* problem ,) > >> > > >> >And I cant recall having this issue when > installing > >> own classloader. > >> > > >> >you should go to eclipse and look for the bug > >> talking about buddy classloading which can handle > >> >this via eclipse classloader madness. > >> > > >> >max > >> > >> No. This is not bug. I understand all Eclipse > >> classloaders "madness". This is feature :) > >> > >> I'll try to describe it again. I do not want make > my > >> entity classes "see" hibernate jar's (because I > want > >> to support pluggable persistence layers, for > example > >> via Hibernate or via JDBC, etc). Saying it > another > >> way, classloader of mine entity classes do not > see > >> hibernate classes - I just _want_ it to be this > way. > >> But when Hibernate generates proxy factory, it > uses > >> default Enhancer "create" method, look at the > >> snippet: > >> > >> return (Factory) Enhancer.create( > >> (interfaces.length==1) ? > >> persistentClass : null, > >> interfaces, > >> NULL_METHOD_INTERCEPTOR > >> ); > >> > >> If you look into the Enhancer source code, you'll > >> see that if classloader was not set explicitly it > >> uses superclass (the class that will be used as > >> superclass for generated proxy) classloader. And > the > >> superclass in this case is mine entity class. So > >> CGLib tries to generate proxy using my entity > >> classloader. But interfaces array contains > >> HibernateProxy interface, and this is class from > >> Hibernate jar, so it is not seen from my entity > >> classloader (this is by desire). So CGLib fails > to > >> generate proxy (with an exception of > >> ClassNotFoundException). > >> > >> That's the problem. I've solved it very simple - > in > >> case of CodeGenerationException thrown from the > >> Enhancer.create(), I call Enhancer again, but > with > >> classloader explicitly set to the > >> Thread.currentThread().getContextClassLoader(). I > >> think this is OK, since ReflectHelper already > uses > >> thread context classloader to load entities > (that's > >> why my entity is loaded by the Hibernate > >> successfully, despite the fact that it is in the > >> different classloader than Hibernate itself). > >> > >> I think the current behaviour of Hibernate is > >> inconsistent - it can load entity classes from > >> unrelated classloader (using the thread context > >> classloader), but it fails to generate proxies > for > >> them (since it requires classloader of entity > >> classes to see HibernateProxy class). > >> > >> The better way, of course, will be the ability to > >> pass Hibernate classloader that will be used both > >> for loading entity and generating proxy for it. > >> > >> > >> > >> > > > ------------------------------------------------------- > >> This SF.Net email is sponsored by: NEC IT Guy > Games. > >> How far can you shotput > >> a projector? How fast can you ride your desk > chair > >> down the office luge track? > >> If you want to score the big prize, get to know > the > >> little guy. > >> Play to win an NEC 61" plasma display: > >> http://www.necitguy.com/?r=20 > >> _______________________________________________ > >> hibernate-devel mailing list > >> hibernate-devel@lists.sourceforge.net > >> > > > https://lists.sourceforge.net/lists/listinfo/hibernate-devel > >> > > > > > > > > > > __________________________________ > > Do you Yahoo!? > > Read only the mail you want - Yahoo! Mail > SpamGuard. > > http://promotions.yahoo.com/new_mail > > > > > > > ------------------------------------------------------- > > SF.Net email is sponsored by: Discover Easy Linux > Migration Strategies > > from IBM. Find simple to follow Roadmaps, > straightforward articles, > > informative Webcasts and more! Get everything you > need to get up to > > speed, fast. > http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click > > _______________________________________________ > > hibernate-devel mailing list > > hibernate-devel@lists.sourceforge.net > > > https://lists.sourceforge.net/lists/listinfo/hibernate-devel > > > > -- > Using Opera's revolutionary e-mail client: > http://www.opera.com/mail/ > > > ------------------------------------------------------- > SF.Net email is sponsored by: Discover Easy Linux > Migration Strategies > from IBM. Find simple to follow Roadmaps, > straightforward articles, > informative Webcasts and more! Get everything you > need to get up to > speed, fast. > http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click > _______________________________________________ > hibernate-devel mailing list > hibernate-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/hibernate-devel > __________________________________ Discover Yahoo! Have fun online with music videos, cool games, IM and more. Check it out! http://discover.yahoo.com/online.html ------------------------------------------------------- SF.Net email is sponsored by: Discover Easy Linux Migration Strategies from IBM. Find simple to follow Roadmaps, straightforward articles, informative Webcasts and more! Get everything you need to get up to speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click _______________________________________________ hibernate-devel mailing list hibernate-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/hibernate-devel