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
http://www.intelligrape.com/
Tags: Grails, integration test
This entry was posted
on January 21st, 2010
at
4:02 pm and is filed under
Grails .
You can follow any responses to this entry through the
RSS 2.0 feed.
You can leave a response, or trackback from your own site.

Thanks!
Unfortunatelly, it only worked with run-app. When I build a WAR, and deployed in Tomcat 6, it doesn’t have this prop. =(
When do grails run-app, it pass a -Dbase.dir=, but in a production environment it doesn’t exists.
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.
Hey,thanks…it helped me a lot…& saved a lot of time.
It even works in Unit tests also.
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.