14

我在 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运行该应用程序,它就像一个魅力。但我真的很想使用 clasic 命令行工具。

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
4

5 回答 5

15

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

于 2013-06-25T15:22:22.437 回答
1

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

于 2013-10-14T15:02:55.737 回答
1

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

替代方法是为 Oracle JDK 使用 Ubuntu PPA: https ://launchpad.net/~webupd8team/+archive/java

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

于 2013-11-25T09:45:08.750 回答
0

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

于 2014-01-10T15:55:58.287 回答
0

如果升级是一个问题,我在 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 安装更好。

于 2013-07-12T20:28:44.073 回答