Grails deployment issues (WAR & Tomcat)

我的未来我决定 提交于 2019-12-03 00:33:32

This isn't about logging, it's about "prodDB.properties". You're getting a FileNotFoundException because it can't write (or possibly rename) it. The user that's running the app must not have write permission in the directory where it's creating the HSQLDB database files.

The default config uses a relative path, so it's writing wherever the app is launching from:

production {
    dataSource {
        dbCreate = "update"
        url = "jdbc:hsqldb:file:prodDb;shutdown=true"
    }
}

One fix is to hard-code the path in DataSource.groovy:

production {
    dataSource {
        dbCreate = "update"
        url = "jdbc:hsqldb:file:/some/writeable/folder/prodDb;shutdown=true"
    }
}

A better one is to enable external configuration files in Config.groovy:

grails.config.locations = ["classpath:${appName}-config.groovy"]

and create foo-config.groovy containing

dataSource {
    url = "jdbc:hsqldb:file:/some/writeable/folder/prodDb;shutdown=true"
}

and put foo-config.groovy in $TOMCAT_HOME/lib which is in Tomcat's classpath (change foo to your app name). This way you can deploy the war to multiple locations and have just a config file override rather than hard-coding a single value in Config.groovy.

I suddenly encountered this problem when I upgraded to Windows 7. I had been using a shortcut to start Tomcat and I set the "Start In" directory to just plain "C:\". Windows 7 does not let non-admin users write into this directory. I created a subdirectory of my user home called "TomcatData" and changed my shortcut to start Tomcat from there. Everything now works fine.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!