我有一个使用 grails run-war 运行的 2.1.1 grails 应用程序。它运行良好,运行了相当长的一段时间,但在 12 到 24 小时后停止。当应用程序失败时,我从不观察它。它总是说“坏”
$ grails run-war
| Done creating WAR target/web-0.1.war
| Running Grails application
Tomcat Server running WAR (output written to: target/tomcat-out.txt)
| Server running. Browse to http://localhost:8090/web
bad
$
最后 3 次失败中有 2 次在输出文件中产生了这个:
2012-10-10 10:22:46,684 [localhost-startStop-2] ERROR loader.WebappClassLoader - The web application [/web] appears to have started a thread named [Poller SunPKCS11-Darwin] but has failed to stop it. This is very likely to create a memory leak.
2012-10-10 10:22:46,694 [localhost-startStop-2] ERROR loader.WebappClassLoader - The web application [/web] appears to have started a thread named [MongoCleaner1292971653] but has failed to stop it. This is very likely to create a memory leak.
但是大多数时候,日志文件中没有任何内容。
即使没有人使用过 webapp,也会发生这种情况,即它处于空闲状态。使用的插件有:
runtime ":mongodb:1.0.0.GA"
runtime ":jquery:1.7.2"
compile ":jquery-ui:1.8.15"
runtime ":resources:1.2-RC1"
// Uncomment these (or add new ones) to enable additional resources capabilities
//runtime ":zipped-resources:1.0"
//runtime ":cached-resources:1.0"
//runtime ":yui-minify-resources:0.1.4"
build ":tomcat:$grailsVersion"
当使用 grails 2.0.4 时,同样的应用程序运行了数周而没有失败。唯一的变化是升级到 grails 2.1.1
有什么想法吗?
谢谢
编辑:包括 DataSource.groovy
dataSource {
pooled = true
driverClassName = "org.h2.Driver"
username = "sa"
password = ""
}
hibernate {
cache.use_second_level_cache = true
cache.use_query_cache = true
cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory'
}
// environment specific settings
environments {
development {
dataSource {
dbCreate = "create-drop" // one of 'create', 'create-drop', 'update', 'validate', ''
url = "jdbc:h2:mem:devDb;MVCC=TRUE"
}
}
test {
dataSource {
dbCreate = "update"
url = "jdbc:h2:mem:testDb;MVCC=TRUE"
}
}
production {
dataSource {
dbCreate = "update"
url = "jdbc:h2:prodDb;MVCC=TRUE"
pooled = true
properties {
maxActive = -1
minEvictableIdleTimeMillis=1800000
timeBetweenEvictionRunsMillis=1800000
numTestsPerEvictionRun=3
testOnBorrow=true
testWhileIdle=true
testOnReturn=true
validationQuery="SELECT 1"
}
}
}
}
然后在每个模型中,
class Album {
static mapWith = "mongo"
我这样做是为了确保每次升级 grails 时都使用 Mongo,即使我一直在卸载它,它也会自动重新安装休眠插件。
谢谢