我正在使用连接到postgres 9.2数据库的 jndi 池数据源,在glassfish 3.1.2.2上运行grails 2.2.1项目。当我第一次部署应用程序时,我没有任何问题,一切正常。
但是,每次我取消部署(或重新部署)我的应用程序时,我的连接池都会停止工作。如果我尝试使用 glassfish 管理控制台 ping,我会收到以下错误:
Avertissement: RAR8054: Exception while creating an unpooled [test] connection for pool [ sample ],
Connection could not be allocated because: No suitable driver found for
jdbc:postgresql://localhost:5432/sample?loginTimeout=0&socketTimeout=0&prepareThreshold=5&unknownLength=2147483647&loglevel=0&tcpkeepalive=false
Grave: RestResponse.getResponse() donne FAILURE.
endpoint = http://localhost:4848/management/domain/resources/ping-connection-pool.json ; attrs = {id=sample}'
我再说一遍:我的连接池在我部署时工作正常(我在“/glassfish/lib”中有 postgresql 驱动程序,我的连接池配置正确,等等),只有在我取消部署时我才有麻烦。这个错误是高度可重现的,我什至做了一个小的 grails 项目来重现这个问题,你只需要在你的 glassfish 服务器上配置一个连接到“示例”数据库 (jndi/sample) 的 jndi 数据源。
这是 github 链接:
https
://github.com/fabier/GlassfishJDBCGrailsPostgresql 和
战争:
https
:
//www.dropbox.com/s/cb9hmgc6lfabl5x/GlassfishJDBCGrailsPostgresql-0.1.war 和 domain.xml 文件:
https:// /www.dropbox.com/s/ljealpfp0zxj2r4/domain.xml
在 grails 方面,我与池的连接是这样配置的:
environments {
production {
dataSource {
dbCreate = "create-drop"
jndiName = "jdbc/sample"
}
}
}
我认为这个错误很严重,因为它会杀死一个可以在其他 web 应用程序或耳朵之间共享的连接池。有关信息,我做了一些研究,感觉它可能是某种与取消部署相关的类卸载程序,我发现 log4j 可能与这个问题有关,所以我尝试了:
-Dorg.apache.catalina.loader.WebappClassLoader.ENABLE_CLEAR_REFERENCES=false
但这没有帮助。
最后一点:其实postgresql驱动是完全卸载的,所以其他使用postgresql驱动的连接池在卸载后就无法使用了。
链接到 Grails 邮件列表中的相同问题:http:
//grails.1312388.n4.nabble.com/Undeploy-on-Glassfish-causes-connection-pool-to-be-no-more-usable-td4643041.html
链接到Glassfish 的 Jira 中的相同问题:http:
//java.net/jira/browse/GLASSFISH-20094
谢谢你的帮助。