From: <leg...@at...> - 2004-07-25 05:27:55
|
The following comment has been added to this issue: Author: Christian Bauer Created: Sun, 25 Jul 2004 12:49 AM Body: Hibernate runs just fine in a webapp, without you copying any lib into the parent classloaders classpath. You most likely have copied libraries where they shouldn't be (e.g. an old Hibernate2.jar in $TOMCAT/lib). Don't mess with your $TOMCAT/lib, just copy the JDBC driver.jar there and all other classes and libraries you need in your webapp to your WEB-INF/lib and WEB-INF/classes, i.e. in your context classpath. If you still have trouble, start with a fresh unzipped package of Tomcat and repeat this procedure. --------------------------------------------------------------------- View this comment: http://opensource.atlassian.com/projects/hibernate/browse/HB-1064?page=comments#action_13799 --------------------------------------------------------------------- View the issue: http://opensource.atlassian.com/projects/hibernate/browse/HB-1064 Here is an overview of the issue: --------------------------------------------------------------------- Key: HB-1064 Summary: CGLIB classes loaded even when reflection optimizer disabled Type: Bug Status: Closed Priority: Minor Resolution: REJECTED Original Estimate: 5 minutes Time Spent: Unknown Remaining: 5 minutes Project: Hibernate2 Components: core Versions: 2.1.3 Assignee: Reporter: Tim Motika Created: Mon, 5 Jul 2004 6:35 AM Updated: Sun, 25 Jul 2004 12:49 AM Environment: All; ( win32 resin / issue when cglib dynamically loaded and not in system classpath, as on a webapp) Description: Running Hibernate from a webapp causes crash on ClassNotFoundException with the cglib in the lib/ non-system path, even when the optimizer is turned off, since it fails, being unable to load net.sf.cglib.reflect.FastClass for some container-related reason (CGLib is probably using Class.forName() which only loads system classes instead of getClass.getClassLoader().loadClass() ). Container behavior aside, Hibernate is breaking encapsulation by loading cglib even when the feature is turned off, then not using it. Suggested fix: Only execute the calls to FastClass.create() conditionally in these three files: ./net/sf/hibernate/persister/AbstractEntityPersister.java:756 ./net/sf/hibernate/type/ComponentType.java:113 ./net/sf/hibernate/util/ReflectHelper.java:156 Related: change usage of Class.forName() to getClass().getClassLoader().loadClass() in CGLIB so that the jar is not pinned to being in the system classpath Hrm. Environmnet is *only* used in these files to check if the optimizer is on. Seems like moving them over to configuration-based checking would be possible. BTW, thanks for the great work on Hibernate! Autopsy: Stack trace, even when the optimizer has been disabled, and Environment.useReflectionOptimizer() returns false. Error: net.sf.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException-->null net.sf.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException-->null at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:208) at net.sf.cglib.reflect.FastClass$Generator.create(FastClass.java:92) at net.sf.cglib.reflect.FastClass.create(FastClass.java:74) at net.sf.hibernate.persister.AbstractEntityPersister.(AbstractEntityPersister.java:756) at net.sf.hibernate.persister.EntityPersister.(EntityPersister.java:714) at net.sf.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:42) at net.sf.hibernate.impl.SessionFactoryImpl.(SessionFactoryImpl.java:137) at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:768) at org.tlala.site.HibernateUtil.start(HibernateUtil.java:183) at org.tlala.site.DBHome.startDB(DBHome.java:86) at org.tlala.site.DBHome.currentSession(DBHome.java:145) at org.tlala.site.DBHome.doBody(DBHome.java:292) at org.tlala.site.DBHome.service(DBHome.java:215) at org.tlala.site.DBHome.service(DBHome.java:176) at com.caucho.server.http.FilterChainServlet.doFilter(FilterChainServlet.java:96) at com.caucho.server.http.Invocation.service(Invocation.java:315) at com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:135) at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:246) at com.caucho.server.http.HttpRequest.handleConnection(HttpRequest.java:164) at com.caucho.server.TcpConnection.run(TcpConnection.java:139) at java.lang.Thread.run(Thread.java:534) Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at net.sf.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:411) at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:195) ... 20 more Caused by: java.lang.NoClassDefFoundError: net/sf/cglib/reflect/FastClass at java.lang.ClassLoader.defineClass0(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:537) ... 26 more --------------------------------------------------------------------- JIRA INFORMATION: This message is automatically generated by JIRA. If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa If you want more information on JIRA, or have a bug to report see: http://www.atlassian.com/software/jira |