Подтвердить что ты не робот

Grails неожиданно выбрасывает ошибку Не удалось определить диалоги Hibernate для имени базы данных

Я использовал grails в версии 2.2.0 на Ubuntu в течение некоторого времени, и все прошло хорошо. Мое приложение прошло отлично. Вчера я обновил свой JDK до 1.7.0_25, и я уверен, что только изменения я сделал. С тех пор все мои приложения вызывают ошибку при вызове run-app (stacktrace внизу).

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, но это не помогло.

Любые идеи, что с ним не так? Я в отчаянии.

Спасибо за вашу помощь.

StackTrace:

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
4b9b3361

Ответ 1

Это связано с изменением 1.7.0_25, которое вызывает проблему при использовании spring -loaded. Он исправлен в Grails 2.2.3, поэтому обновление до этого исправит это. См. http://jira.grails.org/browse/GRAILS-10183

Ответ 2

Замена OpenJDK 1.7.x на OpenJDK 1.6.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

Новая установка Grails 2.3.4 на Fedora 18 имела такую ​​же проблему у меня. Решение в моем случае (спасибо комментарию от Halil) состояло в том, чтобы перейти на JDK 1.7.0_45.