0 Replies Latest reply on Mar 2, 2004 10:16 AM by Stefan Frank

    ClassCastException when  trying to deploy hibernate.sar

    Stefan Frank Newbie

      I'm struggling with a strange problem, that occurs when i try to deploy hibernate as a .sar (as outlined in http://www.hibernate.org/66.html).

      I'm getting:
      16:18:24,002 FATAL [DatasourceConnectionProvider] Could not find datasource: java:/devbaseDS
      java.lang.ClassCastException
      at net.sf.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:54)
      at net.sf.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:83)
      at net.sf.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:64)
      at net.sf.hibernate.cfg.Configuration.buildSettings(Configuration.java:1119)
      at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:748)
      at net.sf.hibernate.jmx.HibernateService.buildSessionFactory(HibernateService.java:176)
      at net.sf.hibernate.jmx.HibernateService.start(HibernateService.java:145)
      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(ReflectedMBeanDispatcher.java:284)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
      at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:976)
      at $Proxy14.start(Unknown Source)
      at org.jboss.system.ServiceController.start(ServiceController.java:394)
      at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
      at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
      at $Proxy4.start(Unknown Source)
      at org.jboss.deployment.SARDeployer.start(SARDeployer.java:226)
      at org.jboss.deployment.MainDeployer.start(MainDeployer.java:832)
      at org.jboss.deployment.MainDeployer.start(MainDeployer.java:824)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:642)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:605)
      at sun.reflect.GeneratedMethodAccessor18.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
      at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
      at $Proxy6.deploy(Unknown Source)
      at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:302)
      at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:458)
      at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:201)
      at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploymentScanner.java:212)
      at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:191)
      16:18:24,017 INFO [HibernateServiceMBean] Could not build SessionFactory using the MBean classpath - will try again using client classpath: Could not find datasource
      16:18:24,076 INFO [SessionFactoryObjectFactory] Factory name: omeHibernate

      when I deploy the .ear containing hibernate and a simnple SessionBean that tries to access it.

      I checked, that the DataSource is really present by making a lookup from the SessionBean - this works fine. There is obviously something bound to the name, as the lookup works, but the following cast produces the exception. I suspected ClassLoader-Errors, so i checked the Loaders which gives me:
      16:18:23,944 INFO [DatasourceConnectionProvider] Object found. Object is a <org.jboss.resource.adapter.jdbc.WrapperDataSource
      16:18:24,000 INFO [DatasourceConnectionProvider] Object is an instance of DataSource:false
      16:18:24,001 INFO [DatasourceConnectionProvider] Classloader for wrapper:org.jboss.mx.loading.UnifiedClassLoader3@ef2c60{ url=file:/data/src/jboss-3.2.3/server/default/tmp/deploy/tmp20677jboss-service.xml ,addedOrder=2}
      16:18:24,002 INFO [DatasourceConnectionProvider] Classloader for DataSourceClassr:org.jboss.mx.loading.UnifiedClassLoader3@15c80a4{ url=file:/data/src/jboss-3.2.3/server/default/tmp/deploy/tmp20731company.ear ,addedOrder=40}

      When I run the same code inside the SessionBean deployed without the hibernate.sar, which only makes a lookup on the DataSource, I get:

      15:59:38,237 INFO [STDOUT] Object found. Object is a <org.jboss.resource.adapter.jdbc.WrapperDataSource
      15:59:38,238 INFO [STDOUT] Object is an instance of DataSource:true
      15:59:38,238 INFO [STDOUT] Classloader for wrapper:org.jboss.mx.loading.UnifiedClassLoader3@ef2c60{ url=file:/data/src/jboss-3.2.3/server/default/tmp/deploy/tmp20677jboss-service.xml ,addedOrder=2}
      15:59:38,239 INFO [STDOUT] Classloader for DataSource:null
      15:59:38,239 INFO [STDOUT] Found the DataSource!

      So it looks like I have some weird Class-Loader-Problems.

      Can anybody shed some light on this issue?!

      cheers
      stf


      I have: