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)
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.
It very simple to migrate Grails 2.3 -(My case , i am using ivy, pom in Grails 2.1.4)
Do a sample project and run - confirm it working. Keep it as reference.
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.)
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.
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 = {
run Grails upgrade
run Grails run-app
Related
I inherited a Grails app that, on a fresh checkout, I can't get to run. Of course the people that originally worked on this project are long gone. I have other Grails projects that run correctly (out of the box) so I know it's not my config.
setup info:
> cat application.properties
#Grails Metadata file
#Tue Jul 09 16:31:14 IST 2013
app.grails.version=2.1.1
app.name=myapp
app.version=0.1
> grails -version
Grails version: 2.1.1
echo $GROOVY_HOME
/cygdrive/c/Users/myuser/.gvm/groovy/current
> echo $GRAILS_HOME
/cygdrive/c/Users/myuser/.gvm/grails/2.1.1
Now the stacktrace:
grails run-app --stacktrace
| Configuring classpath.
Environment set to development
| Configuring classpath.....
| Error Error executing script RunApp: taskdef class org.codehaus.groovy.grails.compiler.GrailsCompiler cannot be found
using the classloader AntClassLoader[] (NOTE: Stack trace has been filtered. Use --verbose to see entire trace.)
java.lang.ClassNotFoundException: org.codehaus.groovy.grails.compiler.GrailsCompiler
at org.apache.tools.ant.AntClassLoader.findClassInComponents(AntClassLoader.java:1361)
at org.apache.tools.ant.AntClassLoader.findClass(AntClassLoader.java:1311)
at org.apache.tools.ant.AntClassLoader.loadClass(AntClassLoader.java:1064)
at org.apache.tools.ant.taskdefs.Definer.addDefinition(Definer.java:594)
at org.apache.tools.ant.taskdefs.Definer.execute(Definer.java:239)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
at com.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1231)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.codehaus.gant.GantBuilder.invokeMethod(GantBuilder.java:99)
at _GrailsCompile_groovy.run(_GrailsCompile_groovy:32)
at _GrailsCompile_groovy$run.call(Unknown Source)
at _GrailsPackage_groovy$run.call(Unknown Source)
at org.codehaus.gant.IncludeTargets.leftShift(IncludeTargets.groovy:59)
at org.codehaus.gant.IncludeTargets$leftShift.call(Unknown Source)
at _GrailsPackage_groovy.run(_GrailsPackage_groovy:38)
at _GrailsPackage_groovy$run.call(Unknown Source)
at _GrailsSettings_groovy$run.call(Unknown Source)
at org.codehaus.gant.IncludeTargets.leftShift(IncludeTargets.groovy:59)
at org.codehaus.gant.IncludeTargets$leftShift.call(Unknown Source)
at _GrailsPlugins_groovy.run(_GrailsPlugins_groovy:33)
at _GrailsPlugins_groovy$run.call(Unknown Source)
at _GrailsRun_groovy$run.call(Unknown Source)
at org.codehaus.gant.IncludeTargets.leftShift(IncludeTargets.groovy:59)
at org.codehaus.gant.IncludeTargets$leftShift.call(Unknown Source)
at _GrailsRun_groovy.run(_GrailsRun_groovy:31)
at _GrailsRun_groovy$run.call(Unknown Source)
at org.codehaus.gant.IncludeTargets.leftShift(IncludeTargets.groovy:59)
at org.codehaus.gant.IncludeTargets$leftShift.call(Unknown Source)
at RunApp.run(RunApp.groovy:25)
at RunApp$run.call(Unknown Source)
at gant.Gant.prepareTargets(Gant.groovy:607)
at com.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1231)
| Error Error executing script RunApp: taskdef class org.codehaus.groovy.grails.compiler.GrailsCompiler cannot be found
using the classloader AntClassLoader[]
Nothing I seem to do gets past this or changes it. Anyone have any ideas how to fix this?
run grails upgrade - Still not sure why this works but I've had to do it on occasion with a fresh checkout.
check dependencies:
grails dependency-report
Check the output for multiple versions of Groovy or Spring in the build configuration.
http://grails.org/doc/latest/ref/Command%20Line/dependency-report.html
use exclusions or specific dependencies in BuildConfig.groovy to use certain version.
make sure to check different configurations since some dependencies might be just in test configuration, and a different version in compile or build. That might sometimes be a problem with dependencies.
references:
http://grails.1312388.n4.nabble.com/Upgrading-a-project-from-1-3-6-to-1-4-0-M1-td3603895.html
Another check:
Make sure you don't have a ~/.ant/lib directory. I have seen that cause strange problems.
rename it if it exists:
mv ~/.ant/lib{,.old}
Try upgrading directly to Grails 2.3.11 since 2.1.x or 2.2.x Grails branches aren't maintained any more. Take a look at the release notes from grails.org website (https://grails.org/Releases) and grails reference manual for upgrade instructions.
You should take a look at these instructions:
Upgrading from 2.1.x to 2.2.x:
http://grails.org/doc/2.2.x/guide/upgradingFromPreviousVersionsOfGrails.html
Upgrading from 2.2.x to 2.3.x:
http://grails.org/doc/2.3.x/guide/upgradingFromPreviousVersionsOfGrails.html
Read all release notes after the version you are upgrading from:
https://grails.org/Releases
Some extra upgrade tips:
remove all plugin dependencies from application.properties files and move them to BuildConfig.groovy
compare grails-app/conf/* and web-app/WEB-INF/* files of an empty application (of a new version) to your application with a diff tool like Meld , WinMerge, etc.
if you have a templates directory , compare that to an empty application (of a new new version) that has templates installed (grails install-templates).
I had a similar problem, and #Beatty's answer didn't work, because that also would give me an error. Following some possible solutions I found here, I fixed this by deleting the target folder in my app's folder
rm -rf target/*
and then, running again grails compile
Hope this helps
I created a fresh Grails 2.4 project, removed hibernate and database migration plugin added latest spring security and mongo db plugin and when I ran grails compile I got following error
| Error Fatal error during compilation java.lang.NoClassDefFoundError: net/sf/ehcache/config/CacheConfiguration (Use --stacktrace to see the full trace)
If I remove spring security plugin it compiles and if I remove mongoDB plugin and use spring-security with hibernate it still works only the combination of spring security with solo mongoDB plugin is giving above error.
Any Idea ?
Looks like spring-security depends on ehcache, but doesn't declare as such. We had a similar problem with the cache plugin depending on ehcache. Add this to the dependencies section of your BuildConfig:
compile "net.sf.ehcache:ehcache-core:2.4.8"
My application uses grails 1.3.7 with quartz scheduler 1.0-RC1 plugin. It runs fine locally on tomcat when I run it using grails run-app. However, when I create a war file using grails prod war and deploy it in WebLogic, I'm getting the below error:
SLF4J: The requested version 1.5.8 by your slf4j binding is not compatible with [1.6]
SLF4J: See http://www.slf4j.org/codes.html#version_mismatch for further details.
log4j:ERROR Error initializing log4j: org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;Ljava/lang/Throwable;)V
java.lang.NoSuchMethodError: org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;Ljava/lang/Throwable;)V
at org.apache.commons.logging.impl.SLF4JLocationAwareLog.trace(SLF4JLocationAwareLog.java:107)
at org.apache.commons.beanutils.BeanUtilsBean.convert(BeanUtilsBean.java:1073)
I figured this is because grails 1.3.7 uses slf4j 1.5.8, but the quartz plugin uses 1.6.0 and hence there's a conflict. I tried to address it by excluding the slf4j-api jar in BuildConfig.groovy like:
plugins {
compile(":quartz:1.0-RC1") { excludes "slf4j-api" }
}
I was hoping the above config entry would prevent slf4j 1.6.0 from being downloaded and resolve the conflict. But it isn't. When I run grails dependency-report, I still see the conflict and I'm unable to deploy the application in WebLogic.
EDIT: Screenshot of the conflict from grails dependency-report:
Any pointers to resolve this?
You have conflict of jar file. Weblogic comes with sl4j by default and your war file should also contain sl4j jar file inside WEB-INF\lib folder. You can try changing class loading to parent last from admin console.
I resolved this issue by using the code below in BuildConfig.groovy to exclude slf4j-api-1.6.0.jar from the packaged war. The suggestion was posted here
grails.war.resources = { stagingDir ->
delete(file:"${stagingDir}/WEB-INF/lib/slf4j-api-1.6.0.jar")
}
I also had to add slf4j-api-1.5.8.jar to the project's lib folder.
I am getting some error while upgrade. What I did was:
I downloaded Grails 2.3.0.M1, extracted, and changed in Eclipse -> Preferences->Groovy->Grails also.
Changed the Groovy compile 1.8 to 2.0.7
I check out my Grails app from svn, it already working app with Grails 2.14.
I changed this one in BuildConfig.groovy
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
Finally I run grails upgrade, I am getting error like this:
Error org.sonatype.aether.collection.DependencyCollectionException: Failed to collect dependencies
So, I removed the previous added lines from BuildConfig.groovy.
Now, Grails upgrade, is working fine. But it downloading lot of jars into ivy-cache.
Once the upgrade is done (success). If I add then again I add those lines to BuildConfig.groovy, everything is working fine.
But, the problem is, I should able to do upgrade in the first time itself. First time even not only upgrade even Grails clean also not working. After upgrade is done only any Grails commands working.
This issue is due to changes in dependency resolution as explained here:
http://grails.org/doc/2.3.0.M1/guide/upgradingFromPreviousVersionsOfGrails.html
For me, resolving this issue boiled down to these simple steps:
In build.config
1.) Add the following line:
grails.project.dependency.resolver = "maven"
2) Change the plugin dependency version of Tomcat
From: build ":tomcat:$grailsVersion"
To: build ":tomcat:7.0.40.1"
3) Change the plugin dependency version of Hibernate
From: runtime ":hibernate:$grailsVersion"
To: runtime ":hibernate:3.6.10.M3"
As the documentation states:
If you are upgrading from Grails 2.2 you need to manually configure
the correct Tomcat and Hibernate plugins in BuildConfig. The upgrade
command will not do this for you!
Hope this helps...
I am using Grails 1.2.1 and Groovy-Grails Tool Suite 3.1.0. Before that I was used 2.5.2.RELEASE of STS. But after upgrading to Groovy-Grails Tool Suite 3.1.0, when I am trying to run the app I am getting the following error:
Welcome to Grails 1.2.1 - http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: C:\Program Files\Grails\grails-1.2.1\
Base Directory: D:\softwares\My_workspace\BluBilling
Resolving dependencies...
Dependencies resolved in 847ms.
Running script C:\Program Files\Grails\grails-1.2.1\scripts\RunApp.groovy
Environment set to development
Plugin [functional-test-1.2.7] not installed, resolving..
Reading remote plugin list ...Plugin 'functional-test' was not found in repository. If it is not stored in a configured repository you will need to install it manually. Type 'grails list-plugins' to find out what plugins are available.
And when I am open Plugin manager I am getting the empty list but in console window getting one plugin and also getting following error:
Welcome to Grails 1.2.1 - http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: C:\Program Files\Grails\grails-1.2.1\
Base Directory: D:\softwares\My_workspace\BluBilling
Resolving dependencies...
Dependencies resolved in 847ms.
Running script C:\Program Files\Grails\grails-1.2.1\scripts\ListPlugins_.groovy
Environment set to development
Reading remote plugin list ...
Plug-ins available in the core repository are listed below:
-------------------------------------------------------------
dummy <0.1 (?)> -- Plugin summary/headline
hibernate <1.3.8> -- Hibernate for Grails
tomcat <1.3.8> -- Apache Tomcat plugin for Grails
webflow <1.3.8.BUILD-SNAPSHOT> -- Spring Web Flow Plugin
Reading remote plugin list ...
Plug-ins available in the default repository are listed below:
-------------------------------------------------------------
No plugins found in repository: https://svn.codehaus.org/grails-plugins
Plug-ins you currently have installed are listed below:
-------------------------------------------------------------
google-chart 0.5.0 -- This plugin adds Google Chart API features to Grails applications.
To find more info about plugin type 'grails plugin-info [NAME]'
To install type 'grails install-plugin [NAME] [VERSION]'
For further info visit http://grails.org/Plugins
Error executing script ListPlugins: grails.util.BuildSettings.getPluginClassesDir()Ljava/io/File;
java.lang.NoSuchMethodError: grails.util.BuildSettings.getPluginClassesDir()Ljava/io/File;
at org.grails.ide.eclipse.runtime.GrailsBuildSettingsDependencyExtractor.getPluginClassesDir(GrailsBuildSettingsDependencyExtractor.java:63)
at org.grails.ide.eclipse.runtime.GrailsBuildSettingsDependencyExtractor.getDependencyData(GrailsBuildSettingsDependencyExtractor.java:217)
at org.grails.ide.eclipse.runtime.GrailsBuildSettingsDependencyExtractor.writeDependencyFile(GrailsBuildSettingsDependencyExtractor.java:201)
at org.grails.ide.eclipse.runtime.DependencyExtractingBuildListener.receiveGrailsBuildEvent(DependencyExtractingBuildListener.java:79)
at gant.Gant$_dispatch_closure4.doCall(Gant.groovy:324)
at gant.Gant$_dispatch_closure6.doCall(Gant.groovy:334)
at gant.Gant$_dispatch_closure6.doCall(Gant.groovy)
at gant.Gant.withBuildListeners(Gant.groovy:344)
at gant.Gant.this$2$withBuildListeners(Gant.groovy)
at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source)
at gant.Gant.dispatch(Gant.groovy:334)
at gant.Gant.this$2$dispatch(Gant.groovy)
at gant.Gant.invokeMethod(Gant.groovy)
at gant.Gant.processTargets(Gant.groovy:495)
at gant.Gant.processTargets(Gant.groovy:480)
Error executing script ListPlugins: grails.util.BuildSettings.getPluginClassesDir()Ljava/io/File;
I tried to install functional-test plugin using the command:
grails install-plugin functional-test
But I am getting the following error:
Welcome to Grails 1.2.1 - http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: C:\Program Files\Grails\grails-1.2.1\
Base Directory: D:\softwares\My_workspace\BluBilling
Resolving dependencies...
Dependencies resolved in 822ms.
Running script C:\Program Files\Grails\grails-1.2.1\scripts\InstallPlugin.groovy
Environment set to development
Reading remote plugin list ...Plugin 'functional-test' was not found in repository. If it is not stored in a configured repository you will need to install it manually. Type 'grails list-plugins' to find out what plugins are available.
Anyone help me please...
Thanks in advance.
Nimmy.
In your console you can see:
For further info visit http://grails.org/Plugins
So, you should go to this page and try to find plugin functional test. On the page of this plugin functional test you can see
Dependency :
compile ":functional-test:2.0.RC1"
Custom repositories :
mavenRepo "http://repository.codehaus.org/"
mavenRepo "http://repository.jboss.org/maven2/"
So, try to add this repositories to the BuildConfig.groovy.
And now current version of grails - 2.2 :)
If it is don't work, try to use last version of plugin: functional-test:2.0.RC1