Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error at application bootstrap after upgrade to grails 2.3.1

Tags:

grails

upgrade

After upgrading my grails app from grails 2.2.4 to grails 2.3.1 the test-app build fails at the application bootstrap with the following error message:

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.

Running the build with --stacktrace --verbose I see the following details (stacktraces reduced to the IMHO relevant lines):

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)

My BootStrap.groovy looks as follows:

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)
    ...

The error occurs at line 3 when the first entity is created.

[edit] I've already adjusted the plugins and dependencies. Here's the part of my 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"
}

What else can I try to fix this error?

like image 643
tmandry Avatar asked Oct 25 '13 21:10

tmandry


1 Answers

Grails 2.3.1 requires Hibernate 3.6.10.2 plugin version. This is mentioned in the release notes: http://grails.org/2.3.1%20Release%20Notes See also http://jira.grails.org/browse/GRAILS-10686

like image 113
Lari Hotari Avatar answered Sep 24 '22 19:09

Lari Hotari