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 2010/07/29 15:31:37 UTC

DO NOT REPLY [Bug 49667] New: JdbcLeakPrevention class can register unregistered JCBC Driver

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

           Summary: JdbcLeakPrevention class can register unregistered
                    JCBC Driver
           Product: Tomcat 7
           Version: 7.0.0
          Platform: PC
        OS/Version: Solaris
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Catalina
        AssignedTo: dev@tomcat.apache.org
        ReportedBy: ArjenCornelis.Knibbe@Getronics.com


Overview
Suppose there is an web application A that uses a database and registers a
Driver with the java.sql.DriverManager, and a web application B that doesn't
use a database but has a jar file in its WEB-INF/lib directory that contains
the same Driver. Suppose you undeploy web application B.
Running the org.apache.catalina.loader.JdbcLeakPrevention class will actually
register the Driver and leave it loaded! The cause is the way the DriverManager
checks whether a ClassLoader has permission to load the Driver. It does that by
calling Class.forName with the ClassLoader, which will load the class if the
class has not been loaded by that ClassLoader. Loading a Driver class triggers
the Driver to register itself. 

Steps to reproduce
Create two web applications: one which registeres a Driver with the
java.sql.Drivermanager and one that uses no database. Put the jar containing
the Driver class in the WEB-INF/lib directory of both applications. Deploy both
in Tomcat. Then undeploy the latter one.
Inspect catalina.out, verify that there are no messages about a JDBC Driver
being forcibly unregistered.
Create a memory dump using jmap and inspect the dump using jhat.

Actual results
The WebappClassLoader for the latter application is still present. Its "rootset
references" page shows two reference chains from class java.sql.DriverManager:
Static reference from java.sql.DriverManager.readDrivers (from class
java.sql.DriverManager) :
--> java.util.Vector@0xeb6eb3f0 (24 bytes) (field elementData:)
--> [Ljava.lang.Object;@0xeb6eb408 (20 bytes) (Element 2 of
[Ljava.lang.Object;@0xeb6eb408:)
--> java.sql.DriverInfo@0xeb6eb420 (20 bytes) (field driverClass:)
--> class oracle.jdbc.driver.OracleDriver (84 bytes) (??:)
--> org.apache.catalina.loader.WebappClassLoader@0xeb5a84a0 (157 bytes) 

and a similar one from java.sql.DriverManager.writeDrivers.

Expected results
The WebappClassLoader is not present in memory anymore.

Build date & platform
Downloaded Core tar.gz from http://tomcat.apache.org/download-70.cgi

-- 
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 49667] JdbcLeakPrevention class can register unregistered JCBC Driver

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

--- Comment #3 from Arjen Knibbe <Ar...@Getronics.com> 2010-08-25 07:37:16 EDT ---
Created an attachment (id=25935)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=25935)
Demo for bug 49667

This tar/zip contains a minimal implementation of the A application as
mentioned in the bug Overview. Application B will follow. Both applications
contain the MySQL JdbC jar file. A pplication A loads the Driver on startup, B
doesn' t.

Starting with a clean Tomcat (no entries in webapps), the bug can be reproduces
as follows:
* copy A.war into webapps, wait until catalina.out shows application A
deployed.
* copy B.war into webapps, wait until catalina.out shows application B
deployed.
* Remove B.war from webapps, wait until catalina.out shows context /B
undeployed. Verify that no warning is issued about a Driver being forcilbly
unloaded.
* Optionally, wait an hour.
* Trigger a memory dump using jmap, inspect the dump using jhat.
* in the All Classes excluding plathform screen, verify that class
com.snt.connect.demo.B.servlet.Servlet is still there.
* Click on the class, then click on its class loader.
* Click on Other Queries/Exclude weak refs, verify that class
java.sql.DriverManager is in the System class references, and that class
com.mysql.jdbc.Driver is in that reference chain.

-- 
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 49667] JdbcLeakPrevention class can register unregistered JCBC Driver

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|                            |FIXED

--- Comment #9 from Mark Thomas <ma...@apache.org> 2010-10-03 13:36:57 EDT ---
Fixed in 6.0.x and will be included in 6.0.30 onwards.

-- 
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 49667] JdbcLeakPrevention class can register unregistered JCBC Driver

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

--- Comment #8 from Arjen Knibbe <Ar...@Getronics.com> 2010-10-01 07:16:52 EDT ---
That was a quick fix Thomas! Thanks a lot.

-- 
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 49667] JdbcLeakPrevention class can register unregistered JCBC Driver

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

Arjen Knibbe <Ar...@Getronics.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Platform|PC                          |Sun

--- Comment #1 from Arjen Knibbe <Ar...@Getronics.com> 2010-07-29 10:08:42 EDT ---
Before making a memory dump, you must wait an hour.

-- 
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 49667] JdbcLeakPrevention class can register unregistered JCBC Driver

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

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

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

--- Comment #2 from Mark Thomas <ma...@apache.org> 2010-08-24 16:51:04 EDT ---
I don't see this error with the latest 7.0.x code. Please test with 7.0.2 and
if you still see the issue please provide sample web applications and the exact
steps to reproduce from a clean 7.0.2 install.

-- 
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 49667] JdbcLeakPrevention class can register unregistered JCBC Driver

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

Arjen Knibbe <Ar...@Getronics.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|WORKSFORME                  |

--- Comment #5 from Arjen Knibbe <Ar...@Getronics.com> 2010-10-01 05:19:17 EDT ---
I added attachments and a description how to repoduce the bugs as requested by
Mark Thomas (comment 2). See comments 3 and 4. Tested with Tomcat 7.0.2 and jdk
6.0.21 on a Solaris machine.

-- 
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 49667] JdbcLeakPrevention class can register unregistered JCBC Driver

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|Catalina                    |Catalina
            Version|7.0.0                       |6.0.29
            Product|Tomcat 7                    |Tomcat 6
   Target Milestone|---                         |default

--- Comment #7 from Mark Thomas <ma...@apache.org> 2010-10-01 07:13:26 EDT ---
Fixed in trunk and will be included in 7.0.3 onwards.

Proposed for 6.0.x

-- 
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 49667] JdbcLeakPrevention class can register unregistered JCBC Driver

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

--- Comment #6 from Mark Thomas <ma...@apache.org> 2010-10-01 06:47:44 EDT ---
Thanks for the sample apps. I can now reproduce this. Looking at a fix now...

-- 
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 49667] JdbcLeakPrevention class can register unregistered JCBC Driver

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

--- Comment #4 from Arjen Knibbe <Ar...@Getronics.com> 2010-08-25 07:39:02 EDT ---
Created an attachment (id=25936)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=25936)
Demo for bug 49667 - Application B

And here is application B. It had to be uploaded separately, since Bugzilla
accepts only 1000Kb as attachment :-(

-- 
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