Return-Path: X-Original-To: apmail-tomcat-dev-archive@www.apache.org Delivered-To: apmail-tomcat-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A957B4ACB for ; Mon, 6 Jun 2011 16:57:33 +0000 (UTC) Received: (qmail 94791 invoked by uid 500); 6 Jun 2011 16:57:32 -0000 Delivered-To: apmail-tomcat-dev-archive@tomcat.apache.org Received: (qmail 94714 invoked by uid 500); 6 Jun 2011 16:57:32 -0000 Mailing-List: contact dev-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Developers List" Delivered-To: mailing list dev@tomcat.apache.org Received: (qmail 94705 invoked by uid 99); 6 Jun 2011 16:57:32 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 06 Jun 2011 16:57:32 +0000 X-ASF-Spam-Status: No, hits=0.7 required=5.0 tests=RCVD_IN_DNSWL_NONE,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [193.252.22.151] (HELO smtp6.freeserve.com) (193.252.22.151) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 06 Jun 2011 16:57:24 +0000 Received: from me-wanadoo.net (localhost [127.0.0.1]) by mwinf3534.me.freeserve.com (SMTP Server) with ESMTP id B0BAD1C0008E for ; Mon, 6 Jun 2011 18:57:03 +0200 (CEST) Received: from me-wanadoo.net (localhost [127.0.0.1]) by mwinf3534.me.freeserve.com (SMTP Server) with ESMTP id A20FD1C0008F for ; Mon, 6 Jun 2011 18:57:03 +0200 (CEST) Received: from mail.homeinbox.net (unknown [2.29.25.131]) by mwinf3534.me.freeserve.com (SMTP Server) with ESMTP id 742561C0008E for ; Mon, 6 Jun 2011 18:57:03 +0200 (CEST) X-ME-UUID: 20110606165703475.742561C0008E@mwinf3534.me.freeserve.com Received: from localhost (localhost [127.0.0.1]) by mail.homeinbox.net (Postfix) with ESMTP id 4116CEAAB3F for ; Mon, 6 Jun 2011 17:57:03 +0100 (BST) X-Virus-Scanned: Debian amavisd-new at homeinbox.net Received: from mail.homeinbox.net ([127.0.0.1]) by localhost (mail.homeinbox.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1oc-Do8HgKNQ for ; Mon, 6 Jun 2011 17:56:56 +0100 (BST) Received: from [192.168.23.9] (study03.dev.local [192.168.23.9]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.homeinbox.net (Postfix) with ESMTPSA id 191D8EAA4F9 for ; Mon, 6 Jun 2011 17:56:56 +0100 (BST) Message-ID: <4DED06D0.3050508@apache.org> Date: Mon, 06 Jun 2011 17:56:48 +0100 From: Mark Thomas User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.2; en-GB; rv:1.9.2.17) Gecko/20110414 Thunderbird/3.1.10 MIME-Version: 1.0 To: Tomcat Developers List Subject: Re: svn commit: r1131263 - in /tomcat/trunk: java/org/apache/catalina/session/JDBCStore.java java/org/apache/catalina/session/LocalStrings.properties webapps/docs/changelog.xml webapps/docs/config/manager.xml References: <20110603221310.7622923889E1@eris.apache.org> In-Reply-To: X-Enigmail-Version: 1.1.1 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit On 06/06/2011 11:59, Keiichi Fujino wrote: > When jdbc-pool or DBCP is used as DB connection pool and > removeAbandoned is "true", > dbConnection is closed because dbConnection is not returned to the > connection pool. > And then, dbConnection is acquired again because dbConnection has been > already closed. > > Should I return the connection to the connection pool? > Or, is the DB connection cached until removeAbandoned works? The connection should be returned to the pool. If you could take care of that, that would be great. Sorry for missing that when I applied the patch. Mark > > > 2011/6/4 : >> Author: markt >> Date: Fri Jun 3 22:13:09 2011 >> New Revision: 1131263 >> >> URL: http://svn.apache.org/viewvc?rev=1131263&view=rev >> Log: >> Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=51264 >> Allow the JDBC persistent session store to use a JNDI datasource to define the database in which sessions are persisted. >> Patch provided by Felix Schumacher. >> >> Modified: >> tomcat/trunk/java/org/apache/catalina/session/JDBCStore.java >> tomcat/trunk/java/org/apache/catalina/session/LocalStrings.properties >> tomcat/trunk/webapps/docs/changelog.xml >> tomcat/trunk/webapps/docs/config/manager.xml >> >> Modified: tomcat/trunk/java/org/apache/catalina/session/JDBCStore.java >> URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/session/JDBCStore.java?rev=1131263&r1=1131262&r2=1131263&view=diff >> ============================================================================== >> --- tomcat/trunk/java/org/apache/catalina/session/JDBCStore.java (original) >> +++ tomcat/trunk/java/org/apache/catalina/session/JDBCStore.java Fri Jun 3 22:13:09 2011 >> @@ -33,6 +33,11 @@ import java.sql.SQLException; >> import java.util.ArrayList; >> import java.util.Properties; >> >> +import javax.naming.Context; >> +import javax.naming.InitialContext; >> +import javax.naming.NamingException; >> +import javax.sql.DataSource; >> + >> import org.apache.catalina.Container; >> import org.apache.catalina.LifecycleException; >> import org.apache.catalina.Loader; >> @@ -102,6 +107,16 @@ public class JDBCStore extends StoreBase >> */ >> protected String driverName = null; >> >> + /** >> + * name of the JNDI resource >> + */ >> + protected String dataSourceName = null; >> + >> + /** >> + * DataSource to use >> + */ >> + protected DataSource dataSource = null; >> + >> // ------------------------------------------------------------- Table & cols >> >> /** >> @@ -436,6 +451,27 @@ public class JDBCStore extends StoreBase >> return (this.sessionLastAccessedCol); >> } >> >> + /** >> + * Set the JNDI name of a DataSource-factory to use for db access >> + * >> + * @param dataSourceName The JNDI name of the DataSource-factory >> + */ >> + public void setDataSourceName(String dataSourceName) { >> + if (dataSourceName == null || "".equals(dataSourceName.trim())) { >> + manager.getContainer().getLogger().warn( >> + sm.getString(getStoreName() + ".missingDataSourceName")); >> + return; >> + } >> + this.dataSourceName = dataSourceName; >> + } >> + >> + /** >> + * Return the name of the JNDI DataSource-factory >> + */ >> + public String getDataSourceName() { >> + return this.dataSourceName; >> + } >> + >> // --------------------------------------------------------- Public Methods >> >> /** >> @@ -866,6 +902,24 @@ public class JDBCStore extends StoreBase >> if (dbConnection != null) >> return (dbConnection); >> >> + if (dataSourceName != null && dataSource == null) { >> + Context initCtx; >> + try { >> + initCtx = new InitialContext(); >> + Context envCtx = (Context) initCtx.lookup("java:comp/env"); >> + this.dataSource = (DataSource) envCtx.lookup(this.dataSourceName); >> + } catch (NamingException e) { >> + manager.getContainer().getLogger().error( >> + sm.getString(getStoreName() + ".wrongDataSource", >> + this.dataSourceName), e); >> + } >> + } >> + >> + if (dataSource != null) { >> + dbConnection = dataSource.getConnection(); >> + return dbConnection; >> + } >> + >> // Instantiate our database driver if necessary >> if (driver == null) { >> try { >> >> Modified: tomcat/trunk/java/org/apache/catalina/session/LocalStrings.properties >> URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/session/LocalStrings.properties?rev=1131263&r1=1131262&r2=1131263&view=diff >> ============================================================================== >> --- tomcat/trunk/java/org/apache/catalina/session/LocalStrings.properties (original) >> +++ tomcat/trunk/java/org/apache/catalina/session/LocalStrings.properties Fri Jun 3 22:13:09 2011 >> @@ -27,6 +27,8 @@ JDBCStore.checkConnectionDBClosed=The da >> JDBCStore.checkConnectionDBReOpenFail=The re-open on the database failed. The database could be down. >> JDBCStore.checkConnectionSQLException=A SQL exception occurred {0} >> JDBCStore.checkConnectionClassNotFoundException=JDBC driver class not found {0} >> +JDBCStore.wrongDataSource=Can't open JNDI DataSource [{0}] >> +JDBCStore.missingDataSourceName=No valid JNDI name was given. >> managerBase.createRandom=Created random number generator for session ID generation in {0}ms. >> managerBase.createSession.ise=createSession: Too many active sessions >> managerBase.sessionTimeout=Invalid session timeout setting {0} >> >> Modified: tomcat/trunk/webapps/docs/changelog.xml >> URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1131263&r1=1131262&r2=1131263&view=diff >> ============================================================================== >> --- tomcat/trunk/webapps/docs/changelog.xml (original) >> +++ tomcat/trunk/webapps/docs/changelog.xml Fri Jun 3 22:13:09 2011 >> @@ -69,6 +69,11 @@ >> without error. (markt) >> >> >> + 51264: Allow the JDBC persistent session store to use a >> + JNDI datasource to define the database in which sessions are persisted. >> + Patch provided by Felix Schumacher. (markt) >> + >> + >> 51274: Add missing i18n strings in PersistentManagerBase. >> Patch provided by Eiji Takahashi. (markt) >> >> >> Modified: tomcat/trunk/webapps/docs/config/manager.xml >> URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/config/manager.xml?rev=1131263&r1=1131262&r2=1131263&view=diff >> ============================================================================== >> --- tomcat/trunk/webapps/docs/config/manager.xml (original) >> +++ tomcat/trunk/webapps/docs/config/manager.xml Fri Jun 3 22:13:09 2011 >> @@ -356,6 +356,13 @@ >> session table.

>> >> >> + >> +

Name of the JNDI resource for a JDBC DataSource-factory. If this option >> + is given and a valid JDBC resource can be found, it will be used and any >> + direct configuration of a JDBC connection via connectionURL >> + and driverName will be ignored.

>> +
>> + >> >>

Java class name of the JDBC driver to be used.

>>
>> >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org >> For additional commands, e-mail: dev-help@tomcat.apache.org >> >> > > > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org For additional commands, e-mail: dev-help@tomcat.apache.org