title: How do I get the Current Working Directory for Grails/Tomcat Webapp?
body: <p>I wrote a Grails webapp for Tomcat that opens and reads from a Berkeley DB on ./data/transactions/foobar.</p>
  
  <p>This code runs fine in my Eclipse environmet.</p>
  
  <p>But when I move it to the server, it spits out this exception.  I am not sure where the current working directory when I deploy the Grails in a WAR file as a webapps web application on the Server.</p>
  
  <pre><code>com.sleepycat.je.EnvironmentNotFoundException: (JE 4.1.10) ./data/transactions/Foobar
  Home directory: ./data/transactions/Foobar ENV_NOT_FOUND: 
  EnvironmentConfig.setAllowCreate is false so environment creation is not permitted, but there are no log files in the environment directory. Environment is invalid and must be closed.
  </code></pre>
  
  <p>My Tomcat install directory on the Linux server is /usr/share/tomcat6.  The webapps root dir is /usr/share/tomcat6/webapps.  We WAR directory is in installed in a subdirectory named "bridge."  The WAR path to my Grails app is in /usr/share/tomcat6/webapps/bridge</p>
  
  <p>I tried putting the ./data/transaction/Foobar in both /usr/share/tomcat6/webapps and /usr/share/tomcat6/webapps/bridge, with no luck.</p>
  
  <p>I also tried putting ./data/transaction/Foobar into /usr/share/tomcat6 install base directory, also with no luck.</p>
  
  <p>The following are the errors I see from the Tomcat server:</p>
  
  <pre><code>Error 500: Executing action [index] of controller[com.ecmhp.ecmdatabridge.generators.GenerateEmiDigestsController] 
  caused exception: (JE 4.1.10) ./data/transactions/Foobar 
      Home directory: ./data/transactions/Foobar ENV_NOT_FOUND: 
      EnvironmentConfig.setAllowCreate is false so environment creation is not permitted, but there are no log files in the environment directory. Environment is invalid and must be closed.
  </code></pre>
  
  <p>Servlet: grails</p>
  
  <p>URI: /bridge/grails/generateEmiDigests/index.dispatch</p>
  
  <pre><code>Exception Message: (JE 4.1.10) ./data/transactions/Foobar 
  Home directory: ./data/transactions/Foobar ENV_NOT_FOUND: 
  EnvironmentConfig.setAllowCreate is false so environment creation is not permitted, but there are no log files in the environment directory. Environment is invalid and must be closed. 
  
  Caused by: (JE 4.1.10) ./data/transactions/Foobar 
      Home directory: ./data/transactions/Foobar ENV_NOT_FOUND: 
      EnvironmentConfig.setAllowCreate is false so environment creation is not permitted, but there are no log files in the environment directory. Environment is invalid and must be closed.
  </code></pre>
  
  <p>Any idea how I can set the current working directory for my Tomcat WAR so that it finds the Berkeley DB ./data/transaction files?  Or any idea I can find out what the current working directory is my Grails app is launched?</p>