Fixing a Grails plugin cache issue
I’ve been working on this small application as I continue to tinker around with Grails, and set the source code management up through GitHub so that I can synchronize across machines. My Mac laptop has 2.1.0RC2 while my PC had 2.0.4 where I planned to upgrade to 2.1.0RC2 as well.
When I thought I was good to go I began running into some really strange errors:
I then attempted to do a “grails clean”, and experiment with creating a new app and copy in the source to see if that would make a difference, but continued to encounter the issue.
However I did notice in the output that it was referencing a c:\users\{user}\.grails\{version} directory and attempted to nuke the version folder, and still had the same issue.
However, deleting the entire .grails directory fixed the issue!
Conclusion
There’s obviously caching going on here, and I’m guessing the auto-wizardry that figures out plugin dependencies got out of sync. So deleting that directory causes Grails to download fresh all the components that it needs to build the app.
Error Signature
Error executing bootstraps: 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’;
Deleting the whole .grails directory is overkill – you just need to delete the project’s folder under the .grails directory, e.g. ‘~/.grails/2.0.4/projects/appname’. If you delete the whole directory you will delete the files for other apps that are working fine.
But there’s an easier approach. Delete these lines in BuildConfig.groovy:
grails.project.class.dir = “target/classes”
grails.project.test.class.dir = “target/test-classes”
grails.project.test.reports.dir = “target/test-reports”
and replace with
grails.project.work.dir = ‘target’
and then everything will be under /target – when you see weird behavior delete the target directory and run ‘grails compile’ to recompile source and re-install your plugins.
Hi Burt – thanks, that’s good advice!
DavidYou may want to look at the other job trends posts, in the Job Trends cargoety. Learning scripting languages is a good idea, but moving completely away from Java may not be a good thing. Do some research on your general area or type of development to determine which language may have the best job prospects. Thanks for reading!