【问题标题】:How to avoid CouldNotDetermineHibernateDialectException error?如何避免 CouldNotDetermineHibernateDialectException 错误?
【发布时间】:2016-04-08 17:35:57
【问题描述】:

我正在将 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')

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

有什么遗漏或者我可以找到问题并解决问题吗?

【问题讨论】:

  • Grails 和 Hibernate 有哪些版本?
  • 你为什么不使用 Oracle 12C aka org.hibernate.dialect.Oracle12cDialect 的休眠方言?
  • 还要确保使用与您的 oracle 版本完全匹配的 jdbc 驱动程序

标签: java oracle grails


【解决方案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]!'?

更新

建议 - 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:

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

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

请尝试 6 条建议。希望对你有帮助。

【讨论】:

  • 是的,但正如我在 cmets 上所说,我们使用的是 Java 8...,而我们使用的 grails 版本是 2.3.9。我已经检查了你之前发送的链接,但还是谢谢:)
  • @Igor 我已经更新了答案。请尝试 6 条建议。我知道这很疯狂。我也为你的解决方案而疯狂:)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-10-29
  • 2018-07-04
  • 1970-01-01
  • 2014-06-03
  • 2010-11-17
  • 2023-03-18
  • 1970-01-01
相关资源
最近更新 更多