【问题标题】:Grails suddenly throws error Could not determine Hibernate dialect for database nameGrails 突然抛出错误无法确定数据库名称的 Hibernate 方言
【发布时间】:2013-06-22 00:56:39
【问题描述】:

我在 Ubuntu 上使用 2.2.0 版本的 grails 有一段时间了,一切都很顺利。我的应用程序运行良好。我昨天将我的 JDK 更新为 1.7.0_25,我确信这是我所做的唯一改变。从那时起,当调用 run-app 时,我所有的应用程序都会抛出错误(底部的堆栈跟踪)。

Could not determine Hibernate dialect for database name [H2]! # or PostgresSQL if postgres is used

我在一个项目上摆弄 webxml 插件,但我认为这不会弄乱其他应用程序。我使用 git 进行版本控制,即使我回到稳定提交,错误仍然会出现。

有趣的是,如果我从 IntelliJ Idea 运行应用程序,它就像一个魅力。但是我真的很想用经典的命令行工具。

IntelliJ 使用以下命令启动应用程序:

/usr/lib/jvm/java-7-oracle/bin/java -Dgrails.home=/usr/share/grails/2.2.0 -Dbase.dir=/home/freeman/Dokumenty/cms/plugins/Diagnostics -Dtools.jar=/usr/lib/jvm/java-7-oracle/lib/tools.jar -Dgroovy.starter.conf=/usr/share/grails/2.2.0/conf/groovy-starter.conf -Xmx512M -XX:MaxPermSize=192m -Didea.launcher.port=7533 -Didea.launcher.bin.path=/home/freeman/programy/idea-IU-117.798/bin -Dfile.encoding=UTF-8 -classpath /usr/share/grails/2.2.0/lib/org.codehaus.groovy/groovy-all/jars/groovy-all-2.0.5.jar:/usr/share/grails/2.2.0/dist/grails-bootstrap-2.2.0.jar:/home/freeman/programy/idea-IU-117.798/lib/idea_rt.jar com.intellij.rt.execution.application.AppMain org.codehaus.groovy.grails.cli.support.GrailsStarter --main org.codehaus.groovy.grails.cli.GrailsScriptRunner --conf /usr/share/grails/2.2.0/conf/groovy-starter.conf run-app

我也尝试删除 ~/.grails/2.2.0/projects/Diagnostics 但这没有帮助。

任何想法有什么问题吗?我很绝望。

感谢您的帮助。

堆栈跟踪:

2013-06-25 11:19:59,754 [localhost-startStop-1] ERROR context.GrailsContextLoader  - Error initializing Grails: 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 [H2]!
Message: 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 [H2]!
Line | Method
->>  334 | innerRun  in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        |    166 | run       in java.util.concurrent.FutureTask
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    724 | run . . . in java.lang.Thread

Caused by 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]!
->>  334 | innerRun  in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        |    166 | run       in java.util.concurrent.FutureTask
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    724 | run . . . in java.lang.Thread

Caused by 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]!
->>  334 | innerRun  in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        |    166 | run       in java.util.concurrent.FutureTask
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    724 | run . . . in java.lang.Thread

Caused by 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]!
->>  334 | innerRun  in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        |    166 | run       in java.util.concurrent.FutureTask
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    724 | run . . . in java.lang.Thread

Caused by 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]!
->>  334 | innerRun  in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        |    166 | run       in java.util.concurrent.FutureTask
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    724 | run . . . in java.lang.Thread

Caused by CouldNotDetermineHibernateDialectException: Could not determine Hibernate dialect for database name [H2]!
->>  334 | innerRun  in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        |    166 | run       in java.util.concurrent.FutureTask
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    724 | run . . . in java.lang.Thread

【问题讨论】:

  • 这里相同,升级相同,错误相同。我使用 Netbeans 而不是 IntelliJ,并且在 Netbeans 中遇到了同样的错误。一旦我明确地将 h2*.jar 文件的路径(我的环境中有多个)添加到整个 Netbeans 库,我就可以从 Netbeans 中运行该应用程序。我仍然不知道如何使命令行工作,但也许这会有所帮助。
  • 感谢您的回答。我猜类路径有些混乱。不过我还没有找到解决办法。
  • 我有同样的问题,我正在使用 grails-2.2.3 :-(

标签: hibernate grails


【解决方案1】:

这是由于 1.7.0_25 中的更改导致使用弹簧加载时出现问题。它已在 Grails 2.2.3 中修复,因此升级到该版本将解决此问题。见http://jira.grails.org/browse/GRAILS-10183

【讨论】:

  • 我升级了,问题消失了(我不得不手动完成,因为 apt-get 的最新版本是 2.2.0 :-/)。无论如何,你为我节省了几个小时。非常感谢!
  • 使用 gvmtool.net - 它是 apt-get 支持的替代品,并且更新非常快。
  • 与 Grails 2.2.3 在 Linux 上的 OpenJDK 1.7.0_25 仍然存在问题,但 Oracle 的 JDK 确实可以工作。
  • 我通过将 java 从 1.7.0_25 升级到 1.7.0_45 解决了这个问题。
【解决方案2】:

用 OpenJDK 1.6.x 替换 OpenJDK 1.7.x 似乎已经为我解决了这个问题(Ubuntu 13.04)。

【讨论】:

    【解决方案3】:

    看来问题与JDK 7(openjdk 7u25)的版本有关。

    替代方案是将 Ubuntu PPA 用于 Oracle JDK: https://launchpad.net/~webupd8team/+archive/java

    这对我来说很好,解决了问题。

    【讨论】:

      【解决方案4】:

      如果升级是一个问题,我在 grails 错误上发表了一条评论,以寻求一种(非破坏性)解决方法,至少在我的情况下它适用于 2.2.1:

      http://jira.grails.org/browse/GRAILS-10183?focusedCommentId=76068&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-76068

      • 下载 springloaded-core-1.1.3.jar 并将其存储在本地(我将其存储在我的源代码树中以便它被签入)
      • 编辑 grailsw

        #### start of hack to workaround GRAILS-10183 (http://jira.grails.org/browse/GRAILS-10183)
        SPRINGLOADED_CORE_1_1_3="../../local-maven-repo/org/springsource/springloaded/springloaded-core/1.1.3/springloaded-core-1.1.3.jar"
        STARTER_CLASSPATH="$SPRINGLOADED_CORE_1_1_3:wrapper/grails-wrapper-runtime-2.2.1.jar:wrapper:."
        #STARTER_CLASSPATH="wrapper/grails-wrapper-runtime-2.2.1.jar:wrapper:."
        #### end of hack to workaround GRAILS-10183 (http://jira.grails.org/browse/GRAILS-10183)
        

      现在,当您使用 grails 包装器时,弹簧加载核心 1.1.3 位于类路径中,并且它可以正常工作。由于 jar 文件和 grailsw 都使用源代码树签入,因此任何签出它的人都可以从修复中受益,这比要求所有人破解他们的本地 grails 安装更好。

      【讨论】:

        【解决方案5】:

        我在 Fedora 18 上新安装的 Grails 2.3.4 遇到了同样的问题。我的解决方案(感谢 Halil 的评论)是升级到 JDK 1.7.0_45。

        【讨论】:

          猜你喜欢
          • 2017-01-31
          • 2011-11-12
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2021-07-02
          • 2022-11-07
          • 2022-01-14
          相关资源
          最近更新 更多