org.hibernate.HibernateException: No local DataSource found for configuration - dataSource property must be set on LocalSessionFactoryBean

Spring JIRA | David Sissoko | 1 decade ago
  1. 0

    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.

    Spring JIRA | 1 decade ago | David Sissoko
    org.hibernate.HibernateException: No local DataSource found for configuration - dataSource property must be set on LocalSessionFactoryBean
  2. 0

    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.

    Spring JIRA | 1 decade ago | David Sissoko
    org.hibernate.HibernateException: No local DataSource found for configuration - dataSource property must be set on LocalSessionFactoryBean
  3. 0

    [SPR-2909] Hibernate 3.2.1; HibernateException No local DataSource found for configuration when schemaUpdate is true - Spring JIRA

    spring.io | 1 year ago
    org.hibernate.HibernateException: No local DataSource found for configuration - dataSource property must be set on LocalSessionFactoryBean
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    [SPR-2909] Hibernate 3.2.1; HibernateException No local DataSource found for configuration when schemaUpdate is true - Spring JIRA

    spring.io | 1 year ago
    org.hibernate.HibernateException: No local DataSource found for configuration - dataSource property must be set on LocalSessionFactoryBean
  6. 0

    assertMappingWithDatabaseConsistent Exception

    unitils | 10 years ago | upolin
    org.hibernate.HibernateException: No local DataSource found for configuration - dataSource property must be set on LocalSessionFactoryBean

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. org.hibernate.HibernateException

      No local DataSource found for configuration - dataSource property must be set on LocalSessionFactoryBean

      at org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider.configure()
    2. Hibernate
      LocalDataSourceConnectionProvider.configure
      1. org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider.configure(LocalDataSourceConnectionProvider.java:48)
      1 frame
    3. Hibernate
      ConnectionProviderFactory.newConnectionProvider
      1. org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:80)
      1 frame
    4. Hibernate
      SchemaExport.drop
      1. org.hibernate.tool.hbm2ddl.SchemaExport$ProviderConnectionHelper.getConnection(SchemaExport.java:431)
      2. org.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:130)
      3. org.hibernate.tool.hbm2ddl.SchemaExport.drop(SchemaExport.java:108)
      3 frames
    5. Hibernate
      SessionFactoryImpl.close
      1. org.hibernate.impl.SessionFactoryImpl.close(SessionFactoryImpl.java:812)
      1 frame
    6. Java RT
      Method.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      4. java.lang.reflect.Method.invoke(Unknown Source)
      4 frames
    7. Hibernate
      LocalSessionFactoryBean$TransactionAwareInvocationHandler.invoke
      1. org.springframework.orm.hibernate3.LocalSessionFactoryBean$TransactionAwareInvocationHandler.invoke(LocalSessionFactoryBean.java:1021)
      1 frame
    8. Unknown
      $Proxy0.close
      1. $Proxy0.close(Unknown Source)
      1 frame