Upgrade from Grails 2.2.2 to 2.4.1

Here’s what was necessary for me to upgrade handful of Grails projects to 2.4.1:

  • Change the grails.version in application.properties
  • grails clean is your friend when changing dependencies
  • change hibernate, tomcat and resources plugin versions to latest
  • kick out the spock plugin and the grails-spock dependency as these come now with Grails
  • the package of Spock’s IntegrationSpec changed and needs adaptation
  • use the applicationContext.xml and web.xml from a fresh 2.4.1 Grails project (be sure to merge in any custom modifications you have)
  • some older plugins we use have not been updated to remove use of the deprecated classes ApplicationHolder, PluginManagerHolder, ConfigurationHolder that were completely removed in 2.4 – this can be fixed by copying those removed classes into your project so they are there again
  • HTTP method restrictions are also checked in unit tests now, so the correct HTTP method needs to be set in tests
  • Anonymous classes caused obscure exceptions (java.lang.NoSuchFieldError this$0, java.lang.VerifyError) in some places – replacing the anonymous class with a closure fixed this problem – this is most likely a Groovy issue
  • tripped over a bug in startGrails.bat – on Windows the file.encoding system property was not set anymore (see GRAILS-11534)
  • upgrade to 2.4.2 was necessary later because of a bug in JSON serialization GRAILS-11513
  • An exception “Cannot create a session after the response has been committed” was fixed by rearranging the code that accessed the session
  • needed to adapt some corner case transaction handling code – this is likely caused by the Spring changes introduced by the newer Spring version
  • GrailsDomainBinder.getMapping was changed from a static method to instance method – easily fixed by just creating an instance
  • Played around with forked execution – we’ll use it for development mode, but not for the tests because of problems with the Geb functional tests
  • Support for the old databinding (with grails.databinding.useSpringBinder = true) doesn’t really work in tests
    • In unit tests the old databinding doesn’t work because the setting isn’t picked up – moving the affected tests to integration tests fixes this
    • dateCreated (which we manually set in some tests) isn’t bound by the setProperties databinding anymore – assigning dateCreated manually works as a workaround
    • the old databinding with setProperties doesn’t work for functional tests in some places – when used in Bootstrap.groovy the legacy databinding setting is not picked up – with constructor databinding it works, but not with setProperties
  • (change local Grails version and Grails version on CI server)
  • somehow when running in production, we needed to add additional dependencies, because missing classes caused ClassNotFoundExceptions. The required dependencies are runtime ‘org.springframework:spring-expression:4.0.5.RELEASE’ and
    runtime ‘org.springframework:spring-aop:4.0.5.RELEASE’

So all in all, the upgrade was not entirely smooth, but all problems could be solved.

This entry was posted in Software. Bookmark the permalink.

12 Responses to Upgrade from Grails 2.2.2 to 2.4.1

Leave a Reply

Your email address will not be published. Required fields are marked *

Please solve this little equation for verifying that you\'re human *