2011-10-30 16 views
5

Tôi đã viết một ứng dụng web Grails cho Tomcat mở và đọc từ một DB Berkeley trên ./data/transactions/foobar.Làm cách nào để lấy Danh mục làm việc hiện tại cho ứng dụng Web Grails/Tomcat?

Mã này chạy tốt trong môi trường Eclipse của tôi.

Nhưng khi tôi di chuyển nó đến máy chủ, nó phun ra ngoại lệ này. Tôi không chắc chắn nơi thư mục làm việc hiện tại khi tôi triển khai Grails trong một tệp tin WAR như một ứng dụng web webapps trên Máy chủ.

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. 

Thư mục cài đặt Tomcat của tôi trên máy chủ Linux là/usr/share/tomcat6. Thư mục gốc của webapps là/usr/share/tomcat6/webapps. Thư mục WAR của chúng tôi được cài đặt trong thư mục con có tên là "bridge". Đường dẫn WAR tới ứng dụng Grails của tôi nằm trong/usr/share/tomcat6/webapps/bridge

Tôi đã thử đặt ./data/transaction/Foobar trong cả/usr/share/tomcat6/webapps và/usr/share/tomcat6/webapps/bridge, không có may mắn.

Tôi cũng đã thử đặt ./data/transaction/Foobar vào/usr/share/tomcat6 cài đặt thư mục cơ sở, cũng không có may mắn.

Sau đây là các lỗi tôi thấy từ máy chủ 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. 

Bất kỳ ý tưởng làm thế nào tôi có thể thiết lập thư mục làm việc hiện tại cho Tomcat WAR của tôi để nó tìm thấy Berkeley DB ./data/transaction files? Hoặc bất kỳ ý tưởng tôi có thể tìm ra những gì các thư mục làm việc hiện tại là ứng dụng Grails của tôi được đưa ra?

Trả lời

1

Nếu bạn cài đặt plugin Console cho grails, bạn chỉ có thể chạy

new File('test.html').absolutePath 

Đối với ứng dụng của chúng tôi, điều này trả về /data/opt/tomcat/5.5/, vì vậy tôi tưởng tượng rằng bạn cần phải đặt thư mục của bạn bên usr/share/tomcat6/data/giao dịch

8

Nếu bạn có thể có được một tổ chức của các 'grailsApplication' đậu, đó là hoặc có thể được autoinjected ở các bộ phận khác nhau của khuôn khổ Grails bạn có thể thử:

grailsApplication.mainContext.servletContext.getRealPath('/data/transactions/foobar') 
Các vấn đề liên quan