Grails Integration Tests : Access your application path « Intelligrape Groovy & Grails Blogs

Grails Integration Tests : Access your application path

Posted by Amit Jain

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/

  • Share/Bookmark
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.

6 Responses to “Grails Integration Tests : Access your application path”

  1. Wanderson Santos says:

    Thanks!

  2. Wanderson Santos says:

    Unfortunatelly, it only worked with run-app. When I build a WAR, and deployed in Tomcat 6, it doesn’t have this prop. =(

  3. Wanderson Santos says:

    When do grails run-app, it pass a -Dbase.dir=, but in a production environment it doesn’t exists.

  4. Amit Jain says:

    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.

  5. Vishal says:

    Hey,thanks…it helped me a lot…& saved a lot of time.
    It even works in Unit tests also.

  6. 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.

Leave a Reply