2011-10-30 11 views
5

Ho scritto una webapp Grails per Tomcat che si apre e legge da un Berkeley DB su ./data/transactions/foobar.Come posso ottenere la directory di lavoro corrente per Grails/Tomcat Webapp?

Questo codice funziona perfettamente nel mio ambiente Eclipse.

Ma quando lo sposto sul server, sputa questa eccezione. Non sono sicuro di dove sia la directory di lavoro corrente quando distribuisco Grails in un file WAR come applicazione web webapps sul 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. 

La mia directory di installazione Tomcat sul server Linux è/usr/share/tomcat6. La directory principale webapps è/usr/share/tomcat6/webapps. La directory WAR è installata in una sottodirectory denominata "bridge". Il percorso WAR per la mia app Grails è in/usr/share/tomcat6/webapps/bridge

Ho provato a mettere il ./data/transaction/Foobar in/usr/share/tomcat6/webapps e/usr/share/tomcat6/webapps/bridge, senza fortuna.

Ho anche provato a mettere ./data/transaction/Foobar nella directory di installazione di/usr/share/tomcat6, anche senza fortuna.

Di seguito sono riportati gli errori che vedo dal server Tomcat:

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. 

Qualsiasi idea come posso impostare la directory di lavoro corrente per il mio Tomcat WAR in modo che trovi i file Berkeley DB ./data/transaction? O qualche idea che io possa scoprire qual è la directory di lavoro corrente in cui viene lanciata la mia app Grails?

risposta

1

Se si installa il plugin Console per graal, si può semplicemente eseguire

new File('test.html').absolutePath 

Per la nostra applicazione, questo ritorna /data/opt/tomcat/5.5/, quindi immagino che è necessario mettere la directory all'interno usr/share/tomcat6/dati/transazioni

8

Se si riesce a ottenere una sospensione del fagiolo 'grailsApplication', che è o può essere autoinjected in diverse parti del framework Grails si può provare:

grailsApplication.mainContext.servletContext.getRealPath('/data/transactions/foobar') 
Problemi correlati