I am developing a Java web-application. The application connects to a Lucene index. I create a singleton instance of IndexSearcher. This instance opens some files. When I redeploy the web-application, the files opened by the earlier instance of IndexSearcher continue to remain open, and another instance is created by the redeployed application. After a few redeploys, the system starts throwing a "too many open files" exception. I would like to close the old instance before redeploying, so that the old files are closed, but I cannot figure out how to do that? Is there a directive in web.xml that's called upon un-deploy, similar to load-on-startup? I'm running the web-application on a jboss server.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…