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?
If you can get a hold of the 'grailsApplication' bean, which is or can be autoinjected in different parts of the Grails framework you can try:
grailsApplication.mainContext.servletContext.getRealPath('/data/transactions/foobar')
If you install the Console plugin for grails, you can just run
new File( 'test.html' ).absolutePath
For our app, this returns /data/opt/tomcat/5.5/, so I imagine that you need to put your directory inside usr/share/tomcat6/data/transactions
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With