1 Reply Latest reply on Oct 26, 2003 1:34 PM by Adrian Brock

    class loading with hibernate...

    cbwilliams Newbie

      I'm running JBoss with hibernate and HSQL and I'm having problems with classloading.

      I've included all my class files and hibernate configuration files in my war file. When my application initializes it finds the config/mapping files for hibernate just fine but I get ClassNotFound exceptions when it tries to resolve the mapped classes.

      2003-10-25 15:58:56,974 INFO [net.sf.hibernate.cfg.Configuration] Configured SessionFactory: /hibernate/sessionFactory
      2003-10-25 15:58:56,974 INFO [net.sf.hibernate.cfg.Configuration] Mapping resource: com/stic/database/jdo/Mailbox.hbm.xml
      2003-10-25 15:58:57,024 ERROR [net.sf.hibernate.cfg.Configuration] Could not compile the mapping document
      java.lang.ClassNotFoundException: com.stic.database.jdo.Mailbox
      at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
      at org.jboss.mx.loading.UnifiedClassLoader.findClass(UnifiedClassLoader.java:401)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
      at org.jboss.mx.loading.UnifiedClassLoader.loadClassLocally(UnifiedClassLoader.java:242)
      at org.jboss.mx.loading.ClassLoadingTask$ThreadTask.run(ClassLoadingTask.java:114)
      at org.jboss.mx.loading.LoadMgr.nextTask(LoadMgr.java:281)
      at org.jboss.mx.loading.UnifiedClassLoader3.loadClass(UnifiedClassLoader3.java:181)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
      at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
      at java.lang.Class.forName0(Native Method)
      at java.lang.Class.forName(Class.java:120)
      at net.sf.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:268)
      at net.sf.hibernate.cfg.Binder.bindClass(Binder.java:73)
      at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:165)
      at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1095)
      at net.sf.hibernate.cfg.Configuration.add(Configuration.java:230)
      at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:252)
      at net.sf.hibernate.cfg.Configuration.addClass(Configuration.java:286)
      at com.stic.database.access.DatabaseIterator.(DatabaseIterator.java:39)
      at com.stic.database.access.TradingPartnerIterator.(TradingPartnerIterator.java:27)
      at com.stic.database.wrapper.MailboxWrapper.insertMailbox(MailboxWrapper.java:36)
      at com.stic.workflow.delegation.impl.action.ArchiveAndCheckSequenceAction.run(ArchiveAndCheckSequenceAction.java:70)
      at org.jbpm.workflow.delegation.impl.DelegationHelper.delegateAction(DelegationHelper.java:29)
      at org.jbpm.workflow.execution.impl.ExecutionEngineImpl.runActionsForEvent(ExecutionEngineImpl.java:44)
      at org.jbpm.workflow.execution.impl.ExecutionEngineImpl.processTransition(ExecutionEngineImpl.java:52)
      at org.jbpm.workflow.execution.impl.ExecutionComponentImpl.startProcessInstance(ExecutionComponentImpl.java:74)
      at org.jbpm.workflow.execution.ejb.impl.ExecutionSessionBean.startProcessInstance(ExecutionSessionBean.java:59)
      at org.jbpm.workflow.execution.ejb.impl.ExecutionSessionBean.startProcessInstance(ExecutionSessionBean.java:46)
      at java.lang.reflect.Method.invoke(Native Method)
      at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:629)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:186)
      at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.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:117)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
      at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
      at org.jboss.ejb.StatelessSessionContainer.internalInvoke(StatelessSessionContainer.java:322)
      at org.jboss.ejb.Container.invoke(Container.java:674)
      at org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invoke(BaseLocalProxyFactory.java:353)
      at org.jboss.ejb.plugins.local.StatelessSessionProxy.invoke(StatelessSessionProxy.java:83)
      at $Proxy66.startProcessInstance(Unknown Source)
      at com.stic.process.impl.ProcessInitiator.startNewDocument(ProcessInitiator.java:96)
      at com.stic.process.impl.ProcessInitiator.run(ProcessInitiator.java:223)
      rethrown as
      net.sf.hibernate.MappingException: persistent class not found: com.stic.database.jdo.Mailbox
      at net.sf.hibernate.cfg.Binder.bindClass(Binder.java:76)
      at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:165)
      at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1095)
      at net.sf.hibernate.cfg.Configuration.add(Configuration.java:230)
      at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:252)
      at net.sf.hibernate.cfg.Configuration.addClass(Configuration.java:286)
      at com.stic.database.access.DatabaseIterator.(DatabaseIterator.java:39)
      at com.stic.database.access.TradingPartnerIterator.(TradingPartnerIterator.java:27)
      at com.stic.database.wrapper.MailboxWrapper.insertMailbox(MailboxWrapper.java:36)
      at com.stic.workflow.delegation.impl.action.ArchiveAndCheckSequenceAction.run(ArchiveAndCheckSequenceAction.java:70)
      at org.jbpm.workflow.delegation.impl.DelegationHelper.delegateAction(DelegationHelper.java:29)
      at org.jbpm.workflow.execution.impl.ExecutionEngineImpl.runActionsForEvent(ExecutionEngineImpl.java:44)
      at org.jbpm.workflow.execution.impl.ExecutionEngineImpl.processTransition(ExecutionEngineImpl.java:52)
      at org.jbpm.workflow.execution.impl.ExecutionComponentImpl.startProcessInstance(ExecutionComponentImpl.java:74)
      at org.jbpm.workflow.execution.ejb.impl.ExecutionSessionBean.startProcessInstance(ExecutionSessionBean.java:59)
      at org.jbpm.workflow.execution.ejb.impl.ExecutionSessionBean.startProcessInstance(ExecutionSessionBean.java:46)
      at java.lang.reflect.Method.invoke(Native Method)
      at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:629)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:186)
      at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.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:117)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
      at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
      at org.jboss.ejb.StatelessSessionContainer.internalInvoke(StatelessSessionContainer.java:322)
      at org.jboss.ejb.Container.invoke(Container.java:674)
      at org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invoke(BaseLocalProxyFactory.java:353)
      at org.jboss.ejb.plugins.local.StatelessSessionProxy.invoke(StatelessSessionProxy.java:83)
      at $Proxy66.startProcessInstance(Unknown Source)
      at com.stic.process.impl.ProcessInitiator.startNewDocument(ProcessInitiator.java:96)
      at com.stic.process.impl.ProcessInitiator.run(ProcessInitiator.java:223)
      2003-10-25 15:58:57,034 ERROR [com.stic.database.access.DatabaseIterator] DatabaseIterator.save threw an exception.

      The offending line of code is a call to Configuration.addClass(Mailbox.class).

      Everything works fine if I add my project's jar file to my jboss server's lib folder. Is this the only way to resolve this?

        • 1. Re: class loading with hibernate...
          Adrian Brock Master

          You (or indirectly hibernate) are trying to access classes in the war
          from a session bean. The session bean cannot see classes
          in the war.

          That is possible with 3.2.2, where Tomcat/Jetty
          can use a unified classloader.

          server/default/lib is another option as you have found.

          Using a manifest entry is another option.

          Regards,
          Adrian