You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2009/04/21 14:28:51 UTC

DO NOT REPLY [Bug 47061] New: JDBCStore for saving sessions doesn't support datasource

https://issues.apache.org/bugzilla/show_bug.cgi?id=47061

           Summary: JDBCStore for saving sessions doesn't support
                    datasource
           Product: Tomcat 6
           Version: 6.0.16
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Keywords: PatchAvailable
          Severity: normal
          Priority: P2
         Component: Catalina
        AssignedTo: dev@tomcat.apache.org
        ReportedBy: britsp@bristol.gov.uk


Created an attachment (id=23518)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=23518)
Patch JDBCStore to use datasource.

We are using the JDBCStore to store sessions. The current implementation can
only be configured with database connection parameters. Each web application
will create and hold on to its own connection to the session store.
Our tomcats contain a large number of webapps, and this causes and unduly large
number of connections to be made to the database. In addition, all our other
database connections are configured using datasources, and so for consistency
we would much prefer to use a datasource.

I have patched JDBCStore to allow the use of datasource to obtain the
connection. I have added a parameter called "datasourceName". If this is
defined it will use this to lookup the datasource in JNDI. If it is not
configured, it will fall back to using direct connection.

Patch is attached.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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


DO NOT REPLY [Bug 47061] JDBCStore for saving sessions doesn't support datasource

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47061





--- Comment #3 from Steve Pugh <br...@bristol.gov.uk>  2009-05-11 02:46:00 PST ---
Created an attachment (id=23639)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=23639)
JDBCStore.java patch 1

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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


DO NOT REPLY [Bug 47061] JDBCStore for saving sessions doesn't support datasource

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47061


Steve Pugh <br...@bristol.gov.uk> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #23518|0                           |1
        is obsolete|                            |




--- Comment #1 from Steve Pugh <br...@bristol.gov.uk>  2009-04-21 07:48:00 PST ---
Created an attachment (id=23521)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=23521)
 Patch JDBCStore to use datasource v2.

Supplied updated version of patch

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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


DO NOT REPLY [Bug 47061] JDBCStore for saving sessions doesn't support datasource

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47061


Mark Thomas <ma...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement




--- Comment #2 from Mark Thomas <ma...@apache.org>  2009-05-01 08:48:56 PST ---
A couple of comments on your patch:
- It appears to more than advertised - eg moving the call to remove(). Should
this be a separate issue?
- The documentation is not updated.
- Think about the visibility of the new attributes and methods you are adding.
I'd probably start them off as private and increase visibility of required.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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


DO NOT REPLY [Bug 47061] JDBCStore for saving sessions doesn't support datasource

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47061





--- Comment #5 from Steve Pugh <br...@bristol.gov.uk>  2009-05-11 02:57:37 PST ---

The patch does indeed move the remove() method. This is because in the original
code, the call to remove() is inside the block of code in save(), which gets
the connection. But the remove() method then gets the connection again! This
isn't such a problem for the "direct connection" method as the connection is
left open after remove() has finished with it. But in the case where the
datasource is being used, the remove() method returns the connection, and then
the connection is then not available to the rest of the save() method.

As you mentioned, maybe this is a separate issue, so I have posted this a
separate patch (patch 1), so that if you decide to treat it separately it will
be easier to do so.

The other patch (patch 2) adds in the code required for datasource support
using JNDI lookup as before. I have also made the new member variables private
as suggested. This patch needs to be applied after patch 1.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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


DO NOT REPLY [Bug 47061] JDBCStore for saving sessions doesn't support datasource

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47061





--- Comment #6 from Steve Pugh <br...@bristol.gov.uk>  2009-06-09 04:07:18 PST ---
Created an attachment (id=23778)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=23778)
New version of JDBCStore supporting datasource only

I have also come up with an alternative for the JDBC session store.
Attached JDBCStoreDS.java is a new file which ONLY supports the datasource
method of getting the connection. Therefore this doesn't require any changes to
the existing "direct connection" version of the code.

The code can be used by adding the following into context.xml

<Manager className="org.apache.catalina.session.PersistentManager"
maxIdleBackup="0">
  <Store className="org.apache.catalina.session.JDBCStoreDS"
datasourceName="java:/comp/env/jdbc/DB-TOMCAT" sessionDataCol="session_data"
sessionIdCol="session_id" sessionLastAccessedCol="last_access"
sessionMaxInactiveCol="max_inactive" sessionTable="tomcat_sessions"
sessionValidCol="valid_session">
  </Store>
</Manager>

where DB-TOMCAT is a datasource defined elsewhere.

There is also an optional parameter "requireDistributable". Setting this to
true will mean sessions will only be persisted to the database if the webapp is
marked as "distributable" in the web.xml. The default is false which means the
the sessions will be persisted anyway.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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


DO NOT REPLY [Bug 47061] JDBCStore for saving sessions doesn't support datasource

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47061

Mark Thomas <ma...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE

--- Comment #7 from Mark Thomas <ma...@apache.org> 2011-06-04 17:33:38 UTC ---
This was implemented (slightly differently for Tomcat 7). I don't see this
feature being back-ported to Tomcat 6.

*** This bug has been marked as a duplicate of bug 51264 ***

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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


DO NOT REPLY [Bug 47061] JDBCStore for saving sessions doesn't support datasource

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47061


Steve Pugh <br...@bristol.gov.uk> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #23521|0                           |1
        is obsolete|                            |




--- Comment #4 from Steve Pugh <br...@bristol.gov.uk>  2009-05-11 02:46:48 PST ---
Created an attachment (id=23640)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=23640)
 JDBCStore.java patch 2

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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