Grails Integration Tests : Access your application path
Hi Friends,
Recently I needed to access my grails application’s path while writing an integration test. I tried to do it with servlet context, Application Holder and few more options. But none worked. Then I encountered the simplest way as given below, which worked.
System.properties['base.dir']
Cheers!
~~Amit Jain~~
amit@intelligrape.com
IntelliGrape Softwares
I was very happy to find this blog.I wanted to say thanks for this awesome read!! I was definitely enjoying every tiny bit of it and I’ve you bookmarked to check out new stuff you publish.
Hey,thanks…it helped me a lot…& saved a lot of time.
It even works in Unit tests also.
I saw that you found the answer here http://stackoverflow.com/questions/491067/how-to-find-the-physical-path-of-a-gsp-file-in-a-deployed-grails-application and you may also try http://stackoverflow.com/questions/1957723/grails-application-root-path if the solution in this blog doesn’t work when we change the base directory during server startup.
When do grails run-app, it pass a -Dbase.dir=, but in a production environment it doesn’t exists.
Unfortunatelly, it only worked with run-app. When I build a WAR, and deployed in Tomcat 6, it doesn’t have this prop. =(
Thanks!