如何避免CouldNotDetermineHibernateDialectException错误?

时间:2016-04-08 17:35:57

标签: java oracle grails

我将oracle从10升级到12,对于这个特定的项目,我收到了这个错误:

<[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1460078994317> <BEA-101162> <User defined listener org.codehaus.groovy.grails.web.context.GrailsContextLoaderListener failed: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManagerPostProcessor': 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 [Oracle]!.
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManagerPostProcessor': 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 [Oracle]!

似乎没有认识到我在DataSource上添加的配置:

dataSource {
    pooled = true
    driverClassName = "oracle.jdbc.OracleDriver"
    dialect = "org.hibernate.dialect.Oracle10gDialect"
}

我们正在使用Java 8,我们对代码有依赖性:

runtime 'com.oracle:ojdbc7:12.1.0.2'
runtime(group: 'com.oracle', name: 'ons', version: '10.2.0.3')

事情是,它正在为另一个项目工作(与这个项目具有相同的结构,但由于某种原因,它不在这里工作)

是否有任何遗漏或任何我可以找到问题并解决问题的方法?

1 个答案:

答案 0 :(得分:1)

java版1.7.0_25发生了这个问题。通过将java 1.7.0_25升级到另一个较高版本将帮助您解决问题。有时降级到1.6.X也有效。但升级是最佳解决方案。

在Grails 2.2.3中已修复。但是在Grails 2.2.3中,Linux上的OpenJDK 1.7.0_25仍然被破坏,Oracle's JDK确实有效。

归功于@ aeischeid

本教程中给出了分步解决方案Connect Grails with Oracle 11g Example Configuration

资源链接:

  1. How do I avoid 'Could not determine Hibernate dialect for database name [H2]!'?
  2. 更新

    建议 - 1:

    this tutorial开始,我收到了两条建议,请尝试以下两个问题 - 您需要安装Grails H2 plugin。添加

    compile ":h2:0.2.6"
    
    grails-app/conf/BuildConfig.groovy区块中

    plugins

    建议 - 2:

    DataSource.groovy中,它们是case sensitive。所以请检查是否存在任何情况(例如username或其他)与案例不匹配。

    资源链接:MASSIVE ERROR ON GRAILS RUN-APP

    建议 - 3:

    danielnaber提供了一些建议 grails compile --refresh-dependencies和/或grails clean可能有所帮助。 您需要在grails-app/conf/DataSource.groovy中配置数据库访问权限(development用于grails run-app和production用于grails war)

    建议 - 4:

    来自this tutorial 删除DataSource.groovy文件并在执行grails clean后重建WAR,这将禁用基于默认文件的数据源

    目前它正在尝试在文件系统上创建数据库但由于您没有权限而失败。

    建议 - 5:

    您可以查看https://github.com/Netflix/Lipstick/issues/8

    建议 - 6:

    当你在那里时,你应该修复你也看到的缓存提供程序警告 - 将hibernate块中'cache.provider_class'的值更改为

       cache.provider_class = 'net.sf.ehcache.hibernate.EhCacheProvider' 
    

    请尝试6条建议。希望它可以帮到你。