grails - 升级到 grails 2.3.1 后应用程序引导出错

标签 grails upgrade

将我的 grails 应用程序从 grails 2.2.4 升级到 grails 2.3.1 后,test-app 构建在应用程序引导时失败,并显示以下错误消息:

Fatal error running tests: Method on class [de.javandry.minigolf.webapp.Role] was used outside of a Grails application. If running in the context of a test using the mocking API or bootstrap Grails correctly.

使用 --stacktrace --verbose 运行构建,我看到以下详细信息(堆栈跟踪简化为恕我直言相关行):

2013-10-25 22:56:27,876 [main] WARN  util.DTDEntityResolver  - recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!
2013-10-25 22:56:28,674 [main] WARN  hibernate.AbstractEhcacheRegionFactory  - Couldn't find a specific ehcache configuration for cache named [de.javandry.minigolf.webapp.Role]; using defaults.
2013-10-25 22:56:32,264 [main] WARN  servlet.DefaultGrailsApplicationAttributes  - ApplicationContext not found in org.codehaus.groovy.grails.APPLICATION_CONTEXT attribute of servlet context.
| Error 2013-10-25 22:56:34,473 [main] ERROR plugins.DefaultGrailsPluginManager  - Error configuring dynamic methods for plugin [hibernate:3.6.10.M3]: org.grails.datastore.gorm.GormStaticApi.setTransactionManager(Lorg/springframework/transaction/PlatformTransactionManager;)V

java.lang.NoSuchMethodError: org.grails.datastore.gorm.GormStaticApi.setTransactionManager(Lorg/springframework/transaction/PlatformTransactionManager;)V
    at org.codehaus.groovy.grails.orm.hibernate.HibernateGormStaticApi.<init>(HibernateGormStaticApi.groovy:67)
    at org.codehaus.groovy.grails.orm.hibernate.HibernateGormEnhancer.getStaticApi(HibernateGormEnhancer.groovy:87)
  ...
    at grails.plugin.hibernate3.HibernatePluginSupport$__clinit__closure3.doCall(HibernatePluginSupport.groovy:444)

...

| Error Fatal error running tests: Method on class [de.javandry.minigolf.webapp.Role] was used outside of a Grails application. If running in the context of a test using the mocking API or bootstrap Grails correctly.
java.lang.IllegalStateException: Method on class [de.javandry.minigolf.webapp.Role] was used outside of a Grails application. If running in the context of a test using the mocking API or bootstrap Grails correctly.
  ...
    at de.javandry.minigolf.webapp.Role.currentGormInstanceApi(Role.groovy)
    at de.javandry.minigolf.webapp.Role$currentGormInstanceApi$0.call(Unknown Source)
  ...
    at de.javandry.minigolf.webapp.Role.save(Role.groovy)
    at de.javandry.minigolf.webapp.Role$save.call(Unknown Source)
  ...
    at BootStrap$_closure1.doCall(BootStrap.groovy:7)

我的 BootStrap.groovy 如下所示:

class BootStrap {
  def init = { servletContext ->
    def adminRole = new Role(authority: 'ROLE_ADMIN').save(flush: true, failOnError: true)
    def userRole = new Role(authority: 'ROLE_USER').save(flush: true, failOnError: true)
    ...

创建第一个实体时,错误发生在第 3 行。

[编辑]我已经调整了插件和依赖项。这是我的 BuildConfig.groovy 的一部分:

def seleniumVersion = "2.21.0"
def gebVersion = "0.9.0"

dependencies {
    test("org.seleniumhq.selenium:selenium-htmlunit-driver:$seleniumVersion") {
        exclude "xml-apis"
    }
    test "org.seleniumhq.selenium:selenium-chrome-driver:$seleniumVersion"
    test "org.seleniumhq.selenium:selenium-firefox-driver:$seleniumVersion"
    test "org.seleniumhq.selenium:selenium-support:$seleniumVersion"

    test "org.gebish:geb-spock:$gebVersion"
}

plugins {
    runtime ":hibernate:3.6.10.M3"
    runtime ":jquery:1.10.2"
    runtime ":resources:1.2.1"
    runtime ":database-migration:1.3.6"

    build ":tomcat:7.0.40.1"

    compile ":cache:1.1.1"
    compile ":spring-security-core:1.2.7.3"
    compile ":webxml:1.4.1"

    test ":geb:$gebVersion"
    test ":build-test-data:2.0.6"
}

我还能尝试什么来修复此错误?

最佳答案

Grails 2.3.1 需要 Hibernate 3.6.10.2 插件版本。发行说明中提到了这一点:http://grails.org/2.3.1%20Release%20Notes 也可以看看 http://jira.grails.org/browse/GRAILS-10686

关于grails - 升级到 grails 2.3.1 后应用程序引导出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19599626/

相关文章:

java - 为什么在Grails项目中每次编辑.css文件时,STS都会部署一个WAR文件?

grails - 分页重置行的复选框

Android:无法更新到 Android SDK 工具,修订版 7

android - 应用程序第一次升级 sqlite 数据库时崩溃

ios - Xcode 9.2 升级导致此错误 : "Command/bin/sh failed with exit code 1"

安卓12 : BLE Scan does not find any devices

objective-c - ios应用升级委托(delegate)

grails - grails ORM,如何快速搜索日期

Grails VM 因错误退出

spring - 在grails中使用Spring Security Core时如何设置密码大小限制?