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

  1. Jeff says:

    I cannot get the test-app integration: to work. We get a NPE before it gets to the test. What did you mean when you said “the package of Spock’s IntegrationSpec changed and needs adaptation”?

    • Sti says:

      Concerning the NPE: if you’re running the tests from an IDE, try running the tests with grails test-app, as I’ve sometimes seen strange errors like this when running tests in IntelliJ (12). If it’s a integration/functional test, maybe you’re running into the NPE in your Bootstrap.groovy? Otherwise it’s hard to tell without any further information.

      By “the package of Spock’s IntegrationSpec changed and needs adaptation” I mean that before the upgrade the import of IntegrationSpec was “import grails.plugin.spock.IntegrationSpec”, afterwards “import grails.test.spock.IntegrationSpec”.

  2. Zachary Klein says:

    Hey, thanks for the great post! I’m not sure exactly what you mean by “copying those removed classes [ApplicationHolder, etc] into your project”. I tried adding those classes to my src/java (using the org.codehaus… package structure), however my legacy plugins don’t seem to find the classes. How exactly did you reintroduce these classes?

    Thanks again!

    • Sti says:

      Hey Zachary,

      by “copying those removed classes [ApplicationHolder, etc] into your project” I meant exactly that – these classes were removed from Grails, so if you (= your legacy plugins) still need them, you can just copy these classes (which luckily have no further dependencies) to your project so they are there again. Please note that in the original post the ConfigurationHolder was missing (besides ApplicationHolder and PluginManagerHolder).

      We put them into the src/groovy in the most basic plugin in our plugin graph (we use a structure of several custom Grails plugins for application modularization). Yes, you need to put them into the exactly same folder/package structure as the originals (i.e. org.codehaus.grails.commons/plugins). And maybe add a good measure of “grails clean” 😉

      Hope this helps to solve your issue

  3. Swapnil says:

    Hi,
    I am upgrading my app from 1.3.7 to 2.4.4. I am facing a problem with java files. When i try to create an instance of a class ( which is a JAVA class ), I get classnotfound exception. What can be the issue? Here is the error

    Error |
    java.lang.RuntimeException: Reloading agent exited via exception, please raise a jira
    Error |
    at org.springsource.loaded.agent.ClassPreProcessorAgentAdapter.transform(ClassPreProcessorAgentAdapter.java:104)
    Error |
    at sun.instrument.TransformerManager.transform(TransformerManager.java:188)
    Error |
    at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:428)
    Error |
    at java.lang.ClassLoader.defineClass1(Native Method)
    Error |
    at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
    Error |
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    Error |
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:455)
    Error |
    at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
    Error |
    at java.net.URLClassLoader$1.run(URLClassLoader.java:367)
    Error |
    at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
    Error |
    at java.security.AccessController.doPrivileged(Native Method)
    Error |
    at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
    Error |
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    Error |
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    Error |
    at com.securonix.application.controllers.dashboard.DashboardController$_closure2.doCall(DashboardController.groovy:280)
    Error |
    at com.securonix.application.controllers.dashboard.DashboardController$_closure2.doCall(DashboardController.groovy)
    Error |
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    Error |
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    Error |
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    Error |
    at java.lang.reflect.Method.invoke(Method.java:483)
    Error |
    at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1270)
    Error |
    at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
    Error |
    at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324)
    Error |
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1207)
    Error |
    at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1110)
    Error |
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1016)
    Error |
    at groovy.lang.Closure.call(Closure.java:423)
    Error |
    at com.securonix.application.controllers.dashboard.DashboardController$_closure2.call(DashboardController.groovy)
    Error |
    at groovy.lang.Closure.call(Closure.java:417)
    Error |
    at com.securonix.application.controllers.dashboard.DashboardController$_closure2.call(DashboardController.groovy)
    Error |
    at com.securonix.application.controllers.dashboard.DashboardController.loadDashboard(DashboardController.groovy)
    Error |
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    Error |
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    Error |
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    Error |
    at java.lang.reflect.Method.invoke(Method.java:483)
    Error |
    at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1270)
    Error |
    at org.codehaus.groovy.grails.web.servlet.mvc.MixedGrailsControllerHelper.invoke(MixedGrailsControllerHelper.java:154)
    Error |
    at org.codehaus.groovy.grails.web.servlet.mvc.AbstractGrailsControllerHelper.handleAction(AbstractGrailsControllerHelper.java:375)
    Error |
    at org.codehaus.groovy.grails.web.servlet.mvc.AbstractGrailsControllerHelper.executeAction(AbstractGrailsControllerHelper.java:252)
    Error |
    at org.codehaus.groovy.grails.web.servlet.mvc.AbstractGrailsControllerHelper.handleURI(AbstractGrailsControllerHelper.java:205)
    Error |
    at org.codehaus.groovy.grails.web.servlet.mvc.AbstractGrailsControllerHelper.handleURI(AbstractGrailsControllerHelper.java:126)
    Error |
    at org.codehaus.groovy.grails.web.servlet.mvc.SimpleGrailsController.handleRequest(SimpleGrailsController.java:72)
    Error |
    at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:50)
    Error |
    at org.codehaus.groovy.grails.web.servlet.GrailsDispatcherServlet.doDispatch(GrailsDispatcherServlet.java:347)
    Error |
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:870)
    Error |
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)
    Error |
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:852)
    Error |
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:620)
    Error |
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
    Error |
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    Error |
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
    Error |
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    Error |
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    Error |
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    Error |
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    Error |
    at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:198)
    Error |
    at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)
    Error |
    at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344)
    Error |
    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261)
    Error |
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    Error |
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    Error |
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:101)
    Error |
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    Error |
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    Error |
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:101)
    Error |
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    Error |
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    Error |
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:101)
    Error |
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    Error |
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    Error |
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:748)
    Error |
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:486)
    Error |
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:411)
    Error |
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:338)
    Error |
    at org.codehaus.groovy.grails.web.mapping.UrlMappingUtils.forwardRequestForUrlMappingInfo(UrlMappingUtils.java:178)
    Error |
    at org.codehaus.groovy.grails.web.mapping.UrlMappingUtils.forwardRequestForUrlMappingInfo(UrlMappingUtils.java:144)
    Error |
    at org.codehaus.groovy.grails.web.mapping.UrlMappingUtils.forwardRequestForUrlMappingInfo(UrlMappingUtils.java:135)
    Error |
    at org.codehaus.groovy.grails.web.mapping.filter.UrlMappingsFilter.doFilterInternal(UrlMappingsFilter.java:216)
    Error |
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    Error |
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    Error |
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    Error |
    at javax.servlet.FilterChain$doFilter.call(Unknown Source)
    Error |
    at org.grails.plugin.resource.DevModeSanityFilter.doFilter(DevModeSanityFilter.groovy:45)
    Error |
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    Error |
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    Error |
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:369)
    Error |
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109)
    Error |
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
    Error |
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)
    Error |
    at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:97)
    Error |
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)
    Error |
    at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:78)
    Error |
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)
    Error |
    at org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter.doFilter(RememberMeAuthenticationFilter.java:119)
    Error |
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)
    Error |
    at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
    Error |
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)
    Error |
    at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:187)
    Error |
    at com.securonix.application.CustomAuthFilter.super$3$doFilter(CustomAuthFilter.groovy)
    Error |
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    Error |
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    Error |
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    Error |
    at java.lang.reflect.Method.invoke(Method.java:483)
    Error |
    at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1270)
    Error |
    at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
    Error |
    at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324)
    Error |
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1207)
    Error |
    at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1110)
    Error |
    at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuperN(ScriptBytecodeAdapter.java:130)
    Error |
    at com.securonix.application.CustomAuthFilter.doFilter(CustomAuthFilter.groovy:370)
    Error |
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)
    Error |
    at org.springframework.security.web.authentication.preauth.AbstractPreAuthenticatedProcessingFilter.doFilter(AbstractPreAuthenticatedProcessingFilter.java:89)
    Error |
    at com.securonix.application.SSOPreAuthenticationFilter.doFilter(SSOPreAuthenticationFilter.groovy)
    Error |
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)
    Error |
    at org.codehaus.groovy.grails.plugins.springsecurity.MutableLogoutFilter.doFilter(MutableLogoutFilter.java:79)
    Error |
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)
    Error |
    at org.springframework.security.saml.SAMLLogoutProcessingFilter.processLogout(SAMLLogoutProcessingFilter.java:169)
    Error |
    at org.springframework.security.saml.SAMLLogoutProcessingFilter.doFilter(SAMLLogoutProcessingFilter.java:93)
    Error |
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)
    Error |
    at org.springframework.security.saml.SAMLLogoutFilter.processLogout(SAMLLogoutFilter.java:157)
    Error |
    at org.springframework.security.saml.SAMLLogoutFilter.doFilter(SAMLLogoutFilter.java:103)
    Error |
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)
    Error |
    at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:187)
    Error |
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)
    Error |
    at org.springframework.security.saml.metadata.MetadataDisplayFilter.doFilter(MetadataDisplayFilter.java:83)
    Error |
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)
    Error |
    at org.springframework.security.saml.SAMLEntryPoint.doFilter(SAMLEntryPoint.java:102)
    Error |
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)
    Error |
    at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:79)
    Error |
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)
    Error |
    at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:168)
    Error |
    at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344)
    Error |
    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261)
    Error |
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    Error |
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    Error |
    at org.codehaus.groovy.grails.web.servlet.mvc.GrailsWebRequestFilter.doFilterInternal(GrailsWebRequestFilter.java:69)
    Error |
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    Error |
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    Error |
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    Error |
    at org.codehaus.groovy.grails.web.filters.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:67)
    Error |
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    Error |
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    Error |
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    Error |
    at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:399)
    Error |
    at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:158)
    Error |
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    Error |
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    Error |
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
    Error |
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    Error |
    at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344)
    Error |
    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261)
    Error |
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    Error |
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    Error |
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
    Error |
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
    Error |
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
    Error |
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
    Error |
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
    Error |
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
    Error |
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
    Error |
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040)
    Error |
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
    Error |
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:315)
    Error |
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    Error |
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    Error |
    at java.lang.Thread.run(Thread.java:745)
    Error |
    Caused by: java.lang.RuntimeException: java.lang.ClassNotFoundException: com.securonix.application.hibernate.tables.PolicyChain
    Error |
    at sl.org.objectweb.asm.ClassWriter.getCommonSuperClass(Unknown Source)
    Error |
    at sl.org.objectweb.asm.ClassWriter.a(Unknown Source)
    Error |
    at sl.org.objectweb.asm.Frame.a(Unknown Source)
    Error |
    at sl.org.objectweb.asm.Frame.a(Unknown Source)
    Error |
    at sl.org.objectweb.asm.MethodWriter.visitMaxs(Unknown Source)
    Error |
    at sl.org.objectweb.asm.ClassReader.a(Unknown Source)
    Error |
    at sl.org.objectweb.asm.ClassReader.b(Unknown Source)
    Error |
    at sl.org.objectweb.asm.ClassReader.accept(Unknown Source)
    Error |
    at sl.org.objectweb.asm.ClassReader.accept(Unknown Source)
    Error |
    at sl.org.objectweb.asm.ClassWriter.toByteArray(Unknown Source)
    Error |
    at org.springsource.loaded.ReloadableType$MergedRewrite$ChainedAdapters.getBytes(ReloadableType.java:926)
    Error |
    at org.springsource.loaded.ReloadableType$MergedRewrite.rewrite(ReloadableType.java:906)
    Error |
    at org.springsource.loaded.ReloadableType.rewriteCallSitesAndDefine(ReloadableType.java:879)
    Error |
    at org.springsource.loaded.ReloadableType.(ReloadableType.java:161)
    Error |
    at org.springsource.loaded.TypeRegistry.addType(TypeRegistry.java:926)
    Error |
    at org.springsource.loaded.agent.SpringLoadedPreProcessor.preProcess(SpringLoadedPreProcessor.java:302)
    Error |
    at org.springsource.loaded.agent.ClassPreProcessorAgentAdapter.transform(ClassPreProcessorAgentAdapter.java:102)
    Error |
    … 165 more

    • Sti says:

      Hard to say without further information – and it’s quite a version step. Here’s general things you can check
      – has the class PolicyChain been renamed or the package changed?
      – is it in the correct folder (that would be src/java)
      – do your other domain/mapping classes have the same problem?

      • Swapnil says:

        Thank for your reply. But the other classes work fine. In the process I have also upgraded to JDK 8. One more thing to add. When I create a war and deploy on tomcat, it works fine. The classnotfound issue does not appear there. What can be the problem?

        Also I have upgraded my hibernate plugin from 3.6.10.10 to hibernate4:4.3.5.4 but this gives me an error. Have you faced this before?

        ERROR context.GrailsContextLoaderListener – Error initializing the application: 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’: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsAnnotationConfiguration.addFilterDefinition(Lorg/hibernate/engine/spi/FilterDefinition;)V

        • Sti says:

          @ClassNotFoundException only in development: you could try disabling forking in BuildConfig.groovy, maybe that helps:

          grails.project.fork = [
          run: false
          ]

          @Hibernate: no, we’re still at 3.6.10.16, no problems with that one.
          The exception looks like it’s incompatible in some place (breaking code changes). In the notes for the Hibernate 4 plugin, it says

          “Hibernate 4 includes some breaking API changes, so not all plugins that work with the Hibernate 3 plugin will work with this one.”

  4. rocky298 says:

    Great post. I was having terrible issues with my upgrade to 2.4.1. This post resolved many of them. Hail to Sti!

    • Sti says:

      Thanks – maybe next time it’ll be me reading your post on upgrading to 3.0 when the time comes 😉

  5. Swapnil says:

    Hi,
    Thanks for the help. I wanted to know what did you mean by this line.

    needed to adapt some corner case transaction handling code – this is likely caused by the Spring changes introduced by the newer Spring version

    I am getting:

    createCriteria is not valid without active transaction. Stacktrace follows:
    org.hibernate.HibernateException: createCriteria is not valid without active transaction
    at grails.plugins.springsecurity.SpringSecurityService.clearCachedRequestmaps(SpringSecurityService.groovy:104)
    at com.securonix.application.controllers.auth.LoginController$_closure3.doCall(LoginController.groovy:99)

    Do you have any idea about this?

    Thanks

    • Sti says:

      by the line “needed to adapt some corner case transaction handling code” I ment a change from

      def tx = transactionManager?.getTransaction(new DefaultTransactionDefinition(TransactionDefinition.PROPAGATION_SUPPORTS))
      if (tx) {

      if (TransactionSynchronizationManager.isActualTransactionActive()) {

      due to changes in transaction handling – it’s a corner case (used only 1 time) for a call with some specific exception handling.

      Concerning your problem: without more details I can’t really say anything specific. Obviously at the location you would need a transaction, but there’s none. (might be due to transactional = false, but in a Controller …? I’m not sure what that would do)

Comments are closed.