org.hibernate.HibernateException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • I try to setup junit test with spring 1.2.6 and hibernate 3.05. When the test ends up, it should drop the whole schema because hbm2ddl.auto=create-drop is set The schema is created at applicationContext creation in the setup method. The schema should be deleted at applicationContext closing but instead it throws an exception: 2005-12-19 19:18:33,054 DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - <Retrieving dependent beans for bean 'userDao'> 2005-12-19 19:18:33,054 DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - <Invoking destroy() on bean with name 'sessionFactory'> 2005-12-19 19:18:33,054 INFO [org.springframework.orm.hibernate3.LocalSessionFactoryBean] - <Closing Hibernate SessionFactory> 2005-12-19 19:18:33,054 INFO [org.hibernate.impl.SessionFactoryImpl] - <closing> 2005-12-19 19:18:33,054 INFO [org.hibernate.tool.hbm2ddl.SchemaExport] - <Running hbm2ddl schema export> 2005-12-19 19:18:33,054 INFO [org.hibernate.tool.hbm2ddl.SchemaExport] - <exporting generated schema to database> 2005-12-19 19:18:33,054 INFO [org.hibernate.connection.ConnectionProviderFactory] - <Initializing connection provider: org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider> 2005-12-19 19:18:33,054 ERROR [org.hibernate.tool.hbm2ddl.SchemaExport] - <schema export unsuccessful> org.hibernate.HibernateException: No local DataSource found for configuration - dataSource property must be set on LocalSessionFactoryBean at org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider.configure(LocalDataSourceConnectionProvider.java:48) at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:80) at org.hibernate.tool.hbm2ddl.SchemaExport$ProviderConnectionHelper.getConnection(SchemaExport.java:431) at org.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:130) at org.hibernate.tool.hbm2ddl.SchemaExport.drop(SchemaExport.java:108) at org.hibernate.impl.SessionFactoryImpl.close(SessionFactoryImpl.java:812) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.orm.hibernate3.LocalSessionFactoryBean$TransactionAwareInvocationHandler.invoke(LocalSessionFactoryBean.java:1021) at $Proxy0.close(Unknown Source) It seems that sessionfactory is closed before Running hbm2ddl schema export. So when schema export executes, no datasource is available.
    via by David Sissoko,
  • I try to setup junit test with spring 1.2.6 and hibernate 3.05. When the test ends up, it should drop the whole schema because hbm2ddl.auto=create-drop is set The schema is created at applicationContext creation in the setup method. The schema should be deleted at applicationContext closing but instead it throws an exception: 2005-12-19 19:18:33,054 DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - <Retrieving dependent beans for bean 'userDao'> 2005-12-19 19:18:33,054 DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - <Invoking destroy() on bean with name 'sessionFactory'> 2005-12-19 19:18:33,054 INFO [org.springframework.orm.hibernate3.LocalSessionFactoryBean] - <Closing Hibernate SessionFactory> 2005-12-19 19:18:33,054 INFO [org.hibernate.impl.SessionFactoryImpl] - <closing> 2005-12-19 19:18:33,054 INFO [org.hibernate.tool.hbm2ddl.SchemaExport] - <Running hbm2ddl schema export> 2005-12-19 19:18:33,054 INFO [org.hibernate.tool.hbm2ddl.SchemaExport] - <exporting generated schema to database> 2005-12-19 19:18:33,054 INFO [org.hibernate.connection.ConnectionProviderFactory] - <Initializing connection provider: org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider> 2005-12-19 19:18:33,054 ERROR [org.hibernate.tool.hbm2ddl.SchemaExport] - <schema export unsuccessful> org.hibernate.HibernateException: No local DataSource found for configuration - dataSource property must be set on LocalSessionFactoryBean at org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider.configure(LocalDataSourceConnectionProvider.java:48) at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:80) at org.hibernate.tool.hbm2ddl.SchemaExport$ProviderConnectionHelper.getConnection(SchemaExport.java:431) at org.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:130) at org.hibernate.tool.hbm2ddl.SchemaExport.drop(SchemaExport.java:108) at org.hibernate.impl.SessionFactoryImpl.close(SessionFactoryImpl.java:812) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.orm.hibernate3.LocalSessionFactoryBean$TransactionAwareInvocationHandler.invoke(LocalSessionFactoryBean.java:1021) at $Proxy0.close(Unknown Source) It seems that sessionfactory is closed before Running hbm2ddl schema export. So when schema export executes, no datasource is available.
    via by David Sissoko,
  • How to init data in JUnit tests
    via Stack Overflow by Zalivaka
    ,
    • org.hibernate.HibernateException: No local DataSource found for configuration - dataSource property must be set on LocalSessionFactoryBean at org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider.configure(LocalDataSourceConnectionProvider.java:48) at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:80) at org.hibernate.tool.hbm2ddl.SchemaExport$ProviderConnectionHelper.getConnection(SchemaExport.java:431) at org.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:130) at org.hibernate.tool.hbm2ddl.SchemaExport.drop(SchemaExport.java:108) at org.hibernate.impl.SessionFactoryImpl.close(SessionFactoryImpl.java:812) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.orm.hibernate3.LocalSessionFactoryBean$TransactionAwareInvocationHandler.invoke(LocalSessionFactoryBean.java:1021) at $Proxy0.close(Unknown Source)
    No Bugmate found.