How to migrate Grails 2.1 to Grails 2.3 application?

守給你的承諾、 提交于 2019-12-21 05:16:37

问题


I am migrating my application from Grails 2.1 to 2.3. I am getting lot of errors after migration - I want some sample applications with Grails 2.3 and Spring integration.

I did some HelloWorld sample applications, and those are working fine. But even I apply same thing in my application, even some where it is giving error. Because my application is very big(100mb) and i am using lot of integration with Spring, Hibernate, and lot of Grails plugins.

I did not find any code level document for "Migrate from Grails 2.1 to Grails 2.3" like that. I am not able to find any sample applications from Grails or online.

Grails official documentation, all about providing Grails META information.

In my main.gsp 229 line:

<g:include controller="filter" action="tree"/>

Caused by: org.codehaus.groovy.grails.web.pages.exceptions.GroovyPagesException: Error processing GroovyPageView: Error executing tag <g:include>: Unable to execute include: Request processing failed; nested exception is org.codehaus.groovy.grails.exceptions.GrailsRuntimeException: java.lang.IllegalStateException: Cannot reset buffer after response has been committed
    at org.codehaus.groovy.grails.web.servlet.view.GroovyPageView.createGroovyPageException(GroovyPageView.java:205)
    at org.codehaus.groovy.grails.web.servlet.view.GroovyPageView.handleException(GroovyPageView.java:182)
    at org.codehaus.groovy.grails.web.servlet.view.GroovyPageView.renderWithTemplateEngine(GroovyPageView.java:153)
    at org.codehaus.groovy.grails.web.servlet.view.GroovyPageView.renderMergedOutputModel(GroovyPageView.java:84)
    at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:264)
    at org.codehaus.groovy.grails.web.sitemesh.SpringMVCViewDecorator.render(SpringMVCViewDecorator.java:67)
    ... 51 more
Caused by: org.codehaus.groovy.grails.web.taglib.exceptions.GrailsTagException: Error executing tag <g:include>: Unable to execute include: Request processing failed; nested exception is org.codehaus.groovy.grails.exceptions.GrailsRuntimeException: java.lang.IllegalStateException: Cannot reset buffer after response has been committed
    at org.codehaus.groovy.grails.web.pages.GroovyPage.throwRootCause(GroovyPage.java:531)
    at org.codehaus.groovy.grails.web.pages.GroovyPage.invokeTag(GroovyPage.java:475)
    at sun.reflect.GeneratedMethodAccessor379.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1243)
    at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
    at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1085)
    at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1110)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:909)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:989)
    at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1110)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:909)
    at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:66)
    at mycompany_dev_testuserdev_ws3_myapp_grails_app_views_layouts_main_gsp$_run_closure2.doCall(main.gsp:229)

回答1:


Compare your Config.groovy and BuildConfig.groovy files to the defaults of an empty new Grails 2.3 application.

The most notable change is that plugin dependencies should not be described in application.properties any more. You should also make sure that you are using the correct version of Grails Tomcat, Hibernate and Scaffolding plugins. Tomcat & Hibernate plugin versions no more are the same as the Grails release version. Scaffolding features have been extracted to separate plugin in Grails 2.3 . Make also sure you use correct scope for plugins (build for tomcat, runtime for hibernate).

It's also recommended to start using the new maven based (uses aether library which is part of maven) dependency resolution. This is done with the setting grails.project.dependency.resolver = "maven" in BuildConfig.groovy . I ran in to strange classloading problems with the old ivy based resolver in Grails 2.3 .

I hope this helps.




回答2:


It very simple to migrate Grails 2.3 -(My case , i am using ivy, pom in Grails 2.1.4)

  1. Do a sample project and run - confirm it working. Keep it as reference.
  2. In your project, move all the jars and plugins from pom to BuildConfig, there is no new formats, as usual that you know already. (Note: Don't miss even one jar or plugin, It will take days to realize that, i did same mistake costs 1 and half day.)
  3. And, copy jars and plugins configurations from SampleProject -> BuildConfig to your project BuildConfig, If you have same jars in you app also, check and remove old versions and kept the latest one.
  4. After copy this in BuildConfig
forkConfig = [maxMemory: 1024, minMemory: 64, debug: false, maxPerm: 256]
 grails.project.fork = [
  test: forkConfig, // configure settings for the test-app JVM
  run: forkConfig, // configure settings for the run-app JVM
  war: forkConfig, // configure settings for the run-war JVM
  console: forkConfig // configure settings for the Swing console JVM
 ]

 grails.project.dependency.resolver = "maven" // or ivy
 grails.project.dependency.resolution = {
  1. run Grails upgrade
  2. run Grails run-app


来源:https://stackoverflow.com/questions/16813031/how-to-migrate-grails-2-1-to-grails-2-3-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!