Link to home
Start Free TrialLog in
Avatar of rleelink
rleelink

asked on

How do I set working directory for Tomcat Grails WAR app?

I wrote a Grails webapp for Tomcat that opens and reads from a Berkeley DB on ./data/transactions/foobar.

This code runs fine in my Eclipse environmet.

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.

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.

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

I tried putting the ./data/transaction/Foobar in both /usr/share/tomcat6/webapps and /usr/share/tomcat6/webapps/bridge, with no luck.

I also tried putting ./data/transaction/Foobar into /usr/share/tomcat6 install base directory, also with no luck.

The following are the errors I see from the Tomcat server:

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.

Servlet: grails

URI: /bridge/grails/generateEmiDigests/index.dispatch

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.

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?
ASKER CERTIFIED SOLUTION
Avatar of xterm
xterm

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rleelink
rleelink

ASKER

Good catch, xterm.  I meant to type "Foobar".  It's not a case mismatch problem.  Hoping for someone to give me hints as to what Tomcat web apps uses as its working directory.
Well, the line:

    URI: /bridge/grails/generateEmiDigests/index.dispatch

...sure implies that it's working directory is /usr/share/tomcat6/webapps, which sounds right to me from memory.

However, I know you say you have copied data/transactions/foobar into that directory.  What happens if you specify an absolute path to /foobar in your application, just out of curiosity?
Putting in the absolute path did not fix it.  However, it turned out to be permission problem.  Opening up the file permissioon of directory ./data/transactions/Foobar fixed the problem
Nice catch!