5

./data/transactions/foobar の Berkeley DB を開いて読み取る Tomcat 用の Grails Web アプリケーションを作成しました。

このコードは、私の Eclipse 環境で正常に動作します。

しかし、サーバーに移動すると、この例外が吐き出されます。サーバー上の webapps Web アプリケーションとして Grails を WAR ファイルにデプロイするときに、現在の作業ディレクトリがどこにあるのかわかりません。

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.

Linux サーバーの Tomcat インストール ディレクトリは /usr/share/tomcat6 です。Web アプリケーションのルート ディレクトリは /usr/share/tomcat6/webapps です。WAR ディレクトリは、「bridge」という名前のサブディレクトリにインストールされます。Grails アプリへの WAR パスは /usr/share/tomcat6/webapps/bridge にあります

./data/transaction/Foobar を /usr/share/tomcat6/webapps と /usr/share/tomcat6/webapps/bridge の両方に配置しようとしましたが、うまくいきませんでした。

また、./data/transaction/Foobar を /usr/share/tomcat6 インストール ベース ディレクトリに配置しようとしましたが、運もありませんでした。

以下は、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.

サーブレット: 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.

Tomcat WAR の現在の作業ディレクトリを設定して、Berkeley DB ./data/transaction ファイルを見つける方法を教えてください。または、Grails アプリが起動されている現在の作業ディレクトリを見つけることができるアイデアはありますか?

4

2 に答える 2

8

Grailsフレームワークのさまざまな部分で自動注入されている、または自動注入できる「grailsApplication」Beanを手に入れることができれば、次のことを試すことができます。

grailsApplication.mainContext.servletContext.getRealPath('/data/transactions/foobar')
于 2011-10-31T17:27:31.980 に答える
1

grails 用のコンソール プラグインをインストールすると、次のように実行できます。

new File( 'test.html' ).absolutePath

私たちのアプリでは、これは /data/opt/tomcat/5.5/ を返すので、ディレクトリを usr/share/tomcat6/data/transactions 内に置く必要があると思います

于 2011-10-31T11:48:45.890 に答える