JodaTime Plugin
  1. JodaTime Plugin
  2. GPJODATIME-13

CouldNotDetermineHibernateDialectException: Could not determine Hibernate dialect for database name [H2]!

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.3
    • Labels:
    • Environment:
      grails-2.0.0.BUILD-SNAPSHOT

      Description

      $ grails run-app
      
      | Compiling 1 source files.
      [from println in Config.groovy] Catalina Base: .
      [from println in Config.groovy] Environment:   DEVELOPMENT
      | Compiling 1 source files.....
      [from println in Config.groovy] Catalina Base: .
      [from println in Config.groovy] Environment:   DEVELOPMENT
      | Running Grails application
      [Thread-7] ERROR BeanBuilder | WARNING: You've configured a custom Hibernate naming strategy 'class org.hibernate.cfg.ImprovedNamingStrategy' in DataSource.groovy, however the class cannot be found.
      Using Grails' default naming strategy: 'org.hibernate.cfg.ImprovedNamingStrategy'
      [Thread-7] ERROR BeanBuilder | WARNING: You've configured a custom Hibernate naming strategy 'class org.hibernate.cfg.ImprovedNamingStrategy' in DataSource.groovy, however the class cannot be found.
      Using Grails' default naming strategy: 'org.hibernate.cfg.ImprovedNamingStrategy'
      
      Configuring Spring Security ...
      [Thread-7] ERROR GrailsContextLoader | Error executing bootstraps: Error creating bean with name 'messageSource': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'hibernateProperties' while setting bean property 'hibernateProperties'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateProperties': Cannot resolve reference to bean 'dialectDetector' while setting bean property 'properties' with key [hibernate.dialect]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dialectDetector': Invocation of init method failed; nested exception is org.codehaus.groovy.grails.orm.hibernate.exceptions.CouldNotDetermineHibernateDialectException: Could not determine Hibernate dialect for database name [H2]!
      org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messageSource': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'hibernateProperties' while setting bean property 'hibernateProperties'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateProperties': Cannot resolve reference to bean 'dialectDetector' while setting bean property 'properties' with key [hibernate.dialect]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dialectDetector': Invocation of init method failed; nested exception is org.codehaus.groovy.grails.orm.hibernate.exceptions.CouldNotDetermineHibernateDialectException: Could not determine Hibernate dialect for database name [H2]!
              at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
              at java.util.concurrent.FutureTask.run(FutureTask.java:166)
              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
              at java.lang.Thread.run(Thread.java:679)
      Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'hibernateProperties' while setting bean property 'hibernateProperties'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateProperties': Cannot resolve reference to bean 'dialectDetector' while setting bean property 'properties' with key [hibernate.dialect]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dialectDetector': Invocation of init method failed; nested exception is org.codehaus.groovy.grails.orm.hibernate.exceptions.CouldNotDetermineHibernateDialectException: Could not determine Hibernate dialect for database name [H2]!
              ... 5 more
      Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'hibernateProperties' while setting bean property 'hibernateProperties'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateProperties': Cannot resolve reference to bean 'dialectDetector' while setting bean property 'properties' with key [hibernate.dialect]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dialectDetector': Invocation of init method failed; nested exception is org.codehaus.groovy.grails.orm.hibernate.exceptions.CouldNotDetermineHibernateDialectException: Could not determine Hibernate dialect for database name [H2]!
              ... 5 more
      Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateProperties': Cannot resolve reference to bean 'dialectDetector' while setting bean property 'properties' with key [hibernate.dialect]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dialectDetector': Invocation of init method failed; nested exception is org.codehaus.groovy.grails.orm.hibernate.exceptions.CouldNotDetermineHibernateDialectException: Could not determine Hibernate dialect for database name [H2]!
              ... 5 more
      Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dialectDetector': Invocation of init method failed; nested exception is org.codehaus.groovy.grails.orm.hibernate.exceptions.CouldNotDetermineHibernateDialectException: Could not determine Hibernate dialect for database name [H2]!
              ... 5 more
      Caused by: org.codehaus.groovy.grails.orm.hibernate.exceptions.CouldNotDetermineHibernateDialectException: Could not determine Hibernate dialect for database name [H2]!
              ... 5 more
      [Thread-7] ERROR GrailsContextLoader | Error executing bootstraps: Error creating bean with name 'messageSource': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'hibernateProperties' while setting bean property 'hibernateProperties'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateProperties': Cannot resolve reference to bean 'dialectDetector' while setting bean property 'properties' with key [hibernate.dialect]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dialectDetector': Invocation of init method failed; nested exception is org.codehaus.groovy.grails.orm.hibernate.exceptions.CouldNotDetermineHibernateDialectException: Could not determine Hibernate dialect for database name [H2]!
      org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messageSource': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'hibernateProperties' while setting bean property 'hibernateProperties'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateProperties': Cannot resolve reference to bean 'dialectDetector' while setting bean property 'properties' with key [hibernate.dialect]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dialectDetector': Invocation of init method failed; nested exception is org.codehaus.groovy.grails.orm.hibernate.exceptions.CouldNotDetermineHibernateDialectException: Could not determine Hibernate dialect for database name [H2]!
              at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
              at java.util.concurrent.FutureTask.run(FutureTask.java:166)
              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
              at java.lang.Thread.run(Thread.java:679)
      Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'hibernateProperties' while setting bean property 'hibernateProperties'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateProperties': Cannot resolve reference to bean 'dialectDetector' while setting bean property 'properties' with key [hibernate.dialect]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dialectDetector': Invocation of init method failed; nested exception is org.codehaus.groovy.grails.orm.hibernate.exceptions.CouldNotDetermineHibernateDialectException: Could not determine Hibernate dialect for database name [H2]!
              ... 5 more
      Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'hibernateProperties' while setting bean property 'hibernateProperties'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateProperties': Cannot resolve reference to bean 'dialectDetector' while setting bean property 'properties' with key [hibernate.dialect]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dialectDetector': Invocation of init method failed; nested exception is org.codehaus.groovy.grails.orm.hibernate.exceptions.CouldNotDetermineHibernateDialectException: Could not determine Hibernate dialect for database name [H2]!
              ... 5 more
      Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateProperties': Cannot resolve reference to bean 'dialectDetector' while setting bean property 'properties' with key [hibernate.dialect]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dialectDetector': Invocation of init method failed; nested exception is org.codehaus.groovy.grails.orm.hibernate.exceptions.CouldNotDetermineHibernateDialectException: Could not determine Hibernate dialect for database name [H2]!
              ... 5 more
      Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dialectDetector': Invocation of init method failed; nested exception is org.codehaus.groovy.grails.orm.hibernate.exceptions.CouldNotDetermineHibernateDialectException: Could not determine Hibernate dialect for database name [H2]!
              ... 5 more
      Caused by: org.codehaus.groovy.grails.orm.hibernate.exceptions.CouldNotDetermineHibernateDialectException: Could not determine Hibernate dialect for database name [H2]!
              ... 5 more
      

      The according DataSource.groovy:

      dataSource {
         pooled         = true
         driverClassName    = "org.h2.Driver"
         username      = "sa"
         password      = ""
      // Adding this causes a different error:
      //   dialect         = org.hibernate.dialect.H2Dialect
      }
      hibernate {
         cache.use_second_level_cache   = true
         cache.use_query_cache         = true
         cache.provider_class         = 'net.sf.ehcache.hibernate.EhCacheProvider'
      }
      
      environments {
         development {
            dataSource {
               dbCreate   = "create-drop" // one of 'create', 'create-drop','update'
               url      = "jdbc:h2:mem:devDB"
            }
         }
         test {
            // test-related stuff
         }
         production {
            // prod-related stuff
         }
      }
      
      1. joda-time_FAILING_ivy-1.2.xml
        3 kB
        Bernhard Areich
      2. joda-time_WORKING_ivy-1.2.xml
        0.4 kB
        Bernhard Areich

        Activity

        Hide
        Bernhard Areich added a comment - - edited

        I was now able to track down the exact file causing the issue: .ivy2/cache/org.grails.plugins/joda-time/ivy-1.2.xml

        With the 'old' version of the file, the app starts up fine. With the new it fails. All other files seem to be unrelated to the problem.

        I've attached the two versions (FAILING & WORKING) of the file.

        Show
        Bernhard Areich added a comment - - edited I was now able to track down the exact file causing the issue: .ivy2/cache/org.grails.plugins/joda-time/ivy-1.2.xml With the 'old' version of the file, the app starts up fine. With the new it fails. All other files seem to be unrelated to the problem. I've attached the two versions (FAILING & WORKING) of the file.
        Hide
        Bernhard Areich added a comment -

        By trial & error I found out that this line is causing the problem:

        <dependency org="joda-time" name="joda-time-hibernate" rev="1.2" force="true" conf="compile->compile(*),master(*);runtime->runtime(*)"/>
        

        So I've found the problem - but what's the solution?
        (I've tried

        compile		(':joda-time:1.2')		{ excludes 'spock', 'joda-time-hibernate' }

        in BuildConfig.groovy - without success)

        Show
        Bernhard Areich added a comment - By trial & error I found out that this line is causing the problem: <dependency org= "joda-time" name= "joda-time-hibernate" rev= "1.2" force= " true " conf= "compile->compile(*),master(*);runtime->runtime(*)" /> So I've found the problem - but what's the solution? (I've tried compile (':joda-time:1.2') { excludes 'spock', 'joda-time-hibernate' } in BuildConfig.groovy - without success)
        Hide
        Uwe Hale added a comment -

        I just added the joda-time plugin and started getting the same error.

        Show
        Uwe Hale added a comment - I just added the joda-time plugin and started getting the same error.
        Hide
        Burt Beckwith added a comment -

        If you create a new 2.0 project and install the joda-time plugin you'll see the problem. It's a dependency issue - you can see by running grails dependency-report or by building a war and looking in the WEB-INF/lib directory that there's a antlr-2.7.5H3.jar and a antlr-2.7.6.jar, ehcache-1.1.jar and ehcache-core-2.4.6.jar, and both hibernate-3.0.5.jar and hibernate-core-3.6.7.Final.jar

        Show
        Burt Beckwith added a comment - If you create a new 2.0 project and install the joda-time plugin you'll see the problem. It's a dependency issue - you can see by running grails dependency-report or by building a war and looking in the WEB-INF/lib directory that there's a antlr-2.7.5H3.jar and a antlr-2.7.6.jar, ehcache-1.1.jar and ehcache-core-2.4.6.jar, and both hibernate-3.0.5.jar and hibernate-core-3.6.7.Final.jar
        Hide
        Robert Fletcher added a comment -

        Joda-Time is next on my list to fix up for Grails 2. I might have to split it into multiple plugins as depending on Hibernate isn't really appropriate in the new no-SQL friendly world

        Show
        Robert Fletcher added a comment - Joda-Time is next on my list to fix up for Grails 2. I might have to split it into multiple plugins as depending on Hibernate isn't really appropriate in the new no-SQL friendly world

          People

          • Assignee:
            Robert Fletcher
            Reporter:
            Bernhard Areich
          • Votes:
            3 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: