New closeMethod for JNDI Resources

posted by mthomas on August 17, 2011 07:46 AM

Apache Tomcat 7 contains a number of new features around database connection pooling, which help administrators keep their application available and serving content, collecting customer information, and supporting their applications. The main one that has garnered a lot of attention is the new JDBC Connection Pool feature introduced by Filip Hanik last year. Another connection pool attribute not yet discussed here on is the new closeMethod for speeding up the closing of JNDI resources that would otherwise be closed during garbage collection.

A Specific Requirement

This feature stemmed from a common challenge for applications that make use of database connection pools attached to databases with limited connections allowed. For instance, if a database allows 50 connections, and an application uses a connection pool of 50 connections, in theory everything should work. However, if the application is reloaded, the existing open connections in the old pool would not close until they have been garbage collected. So the new application connection pool while configured for 50 connections, could run out at 37 if the old connection pool had 13 connections open.

A General Solution

One solution to ensure your active connection pool always has connections available to it is to run garbage collection regularly, or each time an application is restarted. However, forcing a full garbage collection is not a particularly elegant solution to this problem and may cause problems of its own. To address this issue, a new attribute has been added for JNDI resources called closeMethod which allows the system administrator to define a zero-argument method call that allows Tomcat to call on a singleton resource when that resource is no longer required. If this attribute is defined, the method is called when the application is stopped, thus speeding up the clean-up of resources that would otherwise have waited to be cleaned up as part of garbage collection.

For more information on the new closeMethod, please see the section on context.html resource definitions in the official Apache Tomcat documentation.

Mark Thomas is a Senior Software Engineer for the SpringSource Division of VMware, Inc. (NYSE: VMW). Mark has been using and developing Tomcat for over six years. He first got involved in the development of Tomcat when he needed better control over the SSL configuration than was available at the time. After fixing that first bug, he started working his way through the remaining Tomcat bugs and is still going. Along the way Mark has become a Tomcat committer and PMC member, volunteered to be the Tomcat 4 & 7 release manager, created the Tomcat security pages, become a member of the ASF and joined the Apache Security Committee. He also helps maintain the ASF's Bugzilla instances. Mark has a MEng in Electronic and Electrical Engineering from the University of Birmingham, United Kingdom.



Could you post a simple of how a set zero-argument method singleton call?

Fernando Franzini - Java Blog

Configuration example

The example below assumes that, like the re-packaged DBCP included with Tomcat, that the DataSource has a close() method that takes no arguments.

<Resource name="jdbc/EmployeeDB" auth="Container"
description="Employees Database for HR Applications"

nice post

Enterprise is seeing double these platforms a year brought huge boost to online shopping. However, LED by B2C is not the road to go smoothly, on to convert the B2C to B2B, is the long-term and effective e-commerce development. stadium light

Hi thomas

So....When I configured closeMethod="close" the tomcat will close dataSource during undeploy, stop and hot-deploy (update war)?

Fernando Franzini - Java Blog

Le Tag Heuer dernière chaîne

Le Tag Heuer dernière chaîne de mouvement mécanique manuel sur p. 999, comme Cartier classique des montres, par le tal Tag Heuer (Neuchâtel) est situé en Suisse, la conception de l'usine de table de sable, de la recherche et du développement et de la fabrication. Carrera mouvement mécanique combinée avec la fiabilité, la stabilité et la précision de conception moderne, avec le replique montres Tag Heuer passé coeur de la machine maison, ensemble couvert par différents morceaux de la plate-forme.

I have so many research paper

I have so many research paper service reviews for new users. So every user is happy to use this kind essay reviews for good education. Then everyone got best grades in all subjects, and thanks a lot for sharing this information for us.


8 ball pool hack Excellent read, Positive site, where did u come up with the information on this posting?I have read a few of the articles on your website now, and I really like your style. Thanks a million and please keep up the effective work. hack clash of clans android

Pdx Shuttle Service

There is so much in this article that I would never have thought of on my own. Your content gives readers things to think about in an interesting way.
Airport Shuttle PDX

Tech Box

Extremely educational post! There is a great deal of data here that can help any business begin with a fruitful informal communication fight!
macbook repair saskatoon


The new closemethod jindi resources that are shared here on the webpage are so good and interesting. I am so happy that the website shares such superb and interesting posts. Keep up the good work guys buckyballs for sale

From Sport Lemon

These websites are really needed, you can learn a lot.

Error News

This is important, though it's necessary to help you head over to it weblink:

Wyatts appliance recycling

On this page, you'll see my profile, please read this information.
appliance recycling Omaha


Very educating post! I am also much eager to gather more massive details from your site. Great optimization!

Visit here


You have raised a paramount issue..thanks for sharing..i might want to peruse more present issues from this blog..keep posting..
upload images to instagram from pc

The novel close method jinni

The novel close method jinni capital that are purchase an essay communal at this time on the webpage are so high-quality and attractive.

Jugar Vice City Jugar Juegos

Game Network was a European online game and television network company. It was initially owned by Digital Bros. group, but was later sold to Cellcast Group. Game Network was, during its broadcast, the only television channel in Europe dedicated to covering multimedia entertainment, and generally focused on video games.

Play GTA Vice City Online
Play GTA San Andreas Online
Jugar Vice City
Jugar San Andreas
pes 2007 download
pes 2010 pc
Telecharger Minecraft Gratuit
Telecharger Subway Surfers Gratuit
Telecharger FIFA 12 PC
Telecharger IDM Gratuit
The novel close method jinni capital that are

Jual Laptop Notebook PC HP Lenovo Printer Tinta Toner Harga Revi

In this particular article, you will see a summary, satisfy browse this post.
Jual Laptop Murah

cash for my laptop Find out

cash for my laptop Find out how much you could earn for your old laptop with Cash in your Gadgets.laptop wholesale UK

This information is helpful

This information is helpful to experts to research resource for the close methods. The people are using for writing college admission and scholarship essays services. That's used by only students to develop more knowledge and education.

Post new comment

This question is for testing whether you are a human visitor and to prevent automated spam submissions.