Anders, I had almost exactly the same problem with the latest Hibernate2 beta 4 and JBoss 3.2RC4. I also came up with exactly the same workaround independently - replacing bcel.jar with cglib.jar.
As Scott says, it may be something Gavin can change relative to avoiding Class.forName(). Until then, however, you can deploy your application as a scoped ear, jar, war, or sar to avoid this problem. I've used this technique successfully as a replacement for the bcel.jar/cglib.jar shuffle. Place a line similar to this: <loader-repository> com.ejbsol.oboxsample.hibernate:loader=hjasample.ear </loader-repository> in your jboss-app.xml, jboss-service.xml, jboss-web.xml, etc. The JBoss class loading documentation should help clarify this usage. We're deploying Hibernate as a JBoss service and use the same loader-repository name in jboss-service.xml in the sar and in jboss-app.xml in the ear to make everything happy. HTH, Rod -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Anders Engström Sent: Thursday, April 03, 2003 10:39 AM To: [EMAIL PROTECTED] Subject: [JBoss-user] JBoss 3.2RC4 and Hibernate2 Hi. We're having some trouble using Hibernate2 (beta2) on JBoss 3.2RC4. I've discussed the problem on the Hibernate discussion forum (sourceforge) and managed to find a work-around... sort-of :) Below is the initial post (the entire thread can be found at http://sourceforge.net/forum/forum.php?thread_id=841642&forum_id=128638): ==== From Hibernate2 forum: Hi. We're having some problem getting Hibernate2 (b4) to run on JBoss (3.2RC4). We use Hibernate from a Stateless Session EJB, and get the following stack-trace from JBoss when hibernate initializes: [...] 2003-04-01 22:33:40,078 INFO [net.sf.hibernate.cfg.Environment] Hibernate 2.0 beta 4 2003-04-01 22:33:40,086 INFO [net.sf.hibernate.cfg.Environment] loaded properties from resource hibernate.properties: {hibernate.dialect=net.sf.hibern ate.dialect.PostgreSQLDialect, hibernate.show_sql=true, hibernate.connection.datasource=java:/PostgresDS} 2003-04-01 22:33:40,095 INFO [net.sf.hibernate.cfg.Environment] JVM proxy support: true 2003-04-01 22:33:40,107 INFO [net.sf.hibernate.cfg.Configuration] Mapping resource: se/mobilecare/model/ItemModel.hbm.xml 2003-04-01 22:33:40,287 DEBUG [net.sf.hibernate.util.DTDEntityResolver] trying to locate http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd in classpath under net/sf/hibernate/ 2003-04-01 22:33:40,289 DEBUG [net.sf.hibernate.util.DTDEntityResolver] found http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd in classpath 2003-04-01 22:33:40,632 INFO [net.sf.hibernate.mapping.Collection] Mapping class: se.mobilecare.model.ItemModel -> item 2003-04-01 22:33:41,418 WARN [org.jboss.mx.loading.ClassLoadingTask] Duplicate class found: org.apache.bcel.generic.RETURN Current CS: (file:/home/azure/jboss-3.2.0RC4/server/default/tmp/deploy/server/default/de ploy/mobilecare-app.ear/lib/ejb/cglib.jar/75.cglib.jar <no cert ificates>) Duplicate CS: (file:/home/azure/jboss-3.2.0RC4/server/default/lib/bcel.jar <no certificates>) 2003-04-01 22:33:41,419 DEBUG [org.jboss.mx.loading.ClassLoadingTask] Ignoring source of: org.apache.bcel.generic.RETURN from CodeSource: (file:/home/a zure/jboss-3.2.0RC4/server/default/lib/bcel.jar <no certificates>), due to order(0>=0), accepted CodeSource: (file:/home/azure/jboss-3.2.0RC4/server/de fault/tmp/deploy/server/default/deploy/mobilecare-app.ear/lib/ejb/cglib.jar/ 75.cglib.jar <no certificates>) 2003-04-01 22:33:41,439 ERROR [org.jboss.ejb.plugins.LogInterceptor] Unexpected Error: java.lang.NoClassDefFoundError: org/apache/bcel/generic/DCONST at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:140) at net.sf.cglib.CodeGenerator.class$(CodeGenerator.java:63) at net.sf.cglib.CodeGenerator.<init>(CodeGenerator.java:105) at net.sf.cglib.KeyFactoryGenerator.<init>(KeyFactoryGenerator.java:93) at net.sf.cglib.KeyFactory.create(KeyFactory.java:114) at net.sf.hibernate.impl.SessionFactoryImpl.<clinit>(SessionFactoryImpl.java:29 7) at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:57 1) at se.mobilecare.services.ejb.ItemServiceBean.getSession(Unknown Source) at se.mobilecare.services.ejb.ItemServiceBean.findAllItems(Unknown Source) 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 org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(Stateles sSessionContainer.java:629) at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(Cach edConnectionInterceptor.java:186) at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSe ssionInstanceInterceptor.java:72) at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor .java:84) at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT. java:243) at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:104) at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:11 7) at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:198) at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinde rInterceptor.java:122) at org.jboss.ejb.StatelessSessionContainer.internalInvoke(StatelessSessionConta iner.java:322) at org.jboss.ejb.Container.invoke(Container.java:678) 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 org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispat cher.java:284) at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:549) at org.jboss.invocation.local.LocalInvoker.invoke(LocalInvoker.java:101) at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:88) at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:77 ) at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:80) at org.jboss.proxy.ejb.StatelessSessionInterceptor.invoke(StatelessSessionInter ceptor.java:109) at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:82) at $Proxy56.findAllItems(Unknown Source) at se.mobilecare.web.actions.item.List.doExecute(Unknown Source) at webwork.action.ActionSupport.execute(ActionSupport.java:114) at webwork.dispatcher.GenericDispatcher.executeAction(GenericDispatcher.java:11 3) at webwork.dispatcher.ServletDispatcher.service(ServletDispatcher.java:161) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:360) at org.mortbay.jetty.servlet.WebApplicationHandler$Chain.doFilter(WebApplicatio nHandler.java:326) at se.mobilecare.web.filters.DebugFilter.doFilter(Unknown Source) [...] Caused by: java.lang.NoClassDefFoundError: org/apache/bcel/generic/DCONST at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:140) at net.sf.cglib.CodeGenerator.class$(CodeGenerator.java:63) at net.sf.cglib.CodeGenerator.<init>(CodeGenerator.java:105) at net.sf.cglib.KeyFactoryGenerator.<init>(KeyFactoryGenerator.java:93) at net.sf.cglib.KeyFactory.create(KeyFactory.java:114) at net.sf.hibernate.impl.SessionFactoryImpl.<clinit>(SessionFactoryImpl.java:29 7) at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:57 1) at se.mobilecare.services.ejb.ItemServiceBean.getSession(Unknown Source) at se.mobilecare.services.ejb.ItemServiceBean.findAllItems(Unknown Source) 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 org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(Stateles sSessionContainer.java:629) at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(Cach edConnectionInterceptor.java:186) at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSe ssionInstanceInterceptor.java:72) at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor .java:84) at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT. java:243) at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:104) at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:11 7) at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:198) ... 38 more [...] It seems like the bcel library in hibernate (cglib.jar) comflicts with bcel.jar (in JBOSS_HOME/server/default/lib) - but JBoss resolves the conflict and loads classes from cglib.jar (or so the log says...). The cglib.jar is refererenced in the ejb-jar META-INF/MANIFEST.MF. Is this a known issue with JBoss 3.2RC4 (in that case I'll take the problem to JBoss mailing list) or could this be a Hibernate related problem? === I managed to solve the problem by removing the JBOSS_HOME/server/default/lib/bcel.jar and replace it with cglib.jar from the Hibernate2 distribution. But - should the above really happen (and /what/ is happening)? Anyone else having problems running Hibernate2 with JBoss? //Anders -- |===================================| | Anders Engström | | [EMAIL PROTECTED] | | http://www.gnejs.net | |===================================| |Your mind is like an umbrella. | |It doesn't work unless you open it.| | /Frank Zappa | |===================================| ------------------------------------------------------- This SF.net email is sponsored by: ValueWeb: Dedicated Hosting for just $79/mo with 500 GB of bandwidth! No other company gives more support or power for your dedicated server http://click.atdmt.com/AFF/go/sdnxxaff00300020aff/direct/01/ _______________________________________________ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user