5

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、次の詳細が表示されます (スタックトレースは IMHO 関連行に縮小されます)。

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"
}

このエラーを修正するには、他に何ができますか?

4

2 に答える 2

8

Grails 2.3.1 には、Hibernate 3.6.10.2 プラグイン バージョンが必要です。これはリリース ノートに記載されてい ます : http://grails.org/2.3.1%20Release%20Notes

于 2013-10-26T07:28:08.743 に答える