Bug 67664 - IllegalArgumentException in ConnectionPool.getProxyConstructor
Summary: IllegalArgumentException in ConnectionPool.getProxyConstructor
Alias: None
Product: Tomcat Modules
Classification: Unclassified
Component: jdbc-pool (show other bugs)
Version: unspecified
Hardware: PC Linux
: P2 regression (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
: 67697 67757 (view as bug list)
Depends on:
Reported: 2023-10-10 17:41 UTC by tza
Modified: 2023-10-15 19:14 UTC (History)
2 users (show)


Note You need to log in before you can comment on or make changes to this bug.
Description tza 2023-10-10 17:41:06 UTC
With the update to tomcat 9.0.81 (due to the released CVE) we run into an IllegalArgumentException.

Looking at the previous implementation before (9.0.80), it seems like some refactoring issue. I hope i chose the right project/component and I didnt find a similar bug report yet.

Previous implementation did 
Proxy.getProxyClass(ConnectionPool.class.getClassLoader(), new Class[] {java.sql.Connection.class,javax.sql.PooledConnection.class});

New implementation is 
Proxy.getProxyClass(ConnectionPool.class.getClassLoader(), new Class[] {Connection.class,PooledConnection.class});
-> Connection has import to java.sql.Connection.class and works as before.
-> PooledConnection has no import and now resolves to org.apache.tomcat.jdbc.pool.PooledConnection and leads to the IllegalArgumentException (was javax.sql.PooledConnection previous).

Caused by: java.sql.SQLException
	at org.apache.tomcat.jdbc.pool.ConnectionPool.setupConnection(ConnectionPool.java:351)
	at org.apache.tomcat.jdbc.pool.ConnectionPool.getConnection(ConnectionPool.java:200)
	at org.apache.tomcat.jdbc.pool.DataSourceProxy.getConnection(DataSourceProxy.java:133)
	at customer.Database.getConnection(Database.java:67)
	... 43 more
Caused by: java.lang.IllegalArgumentException: org.apache.tomcat.jdbc.pool.PooledConnection is not an interface
	at java.base/java.lang.reflect.Proxy$ProxyBuilder.validateProxyInterfaces(Proxy.java:691)
	at java.base/java.lang.reflect.Proxy$ProxyBuilder.<init>(Proxy.java:630)
	at java.base/java.lang.reflect.Proxy.lambda$getProxyConstructor$1(Proxy.java:428)
	at java.base/jdk.internal.loader.AbstractClassLoaderValue$Memoizer.get(AbstractClassLoaderValue.java:329)
	at java.base/jdk.internal.loader.AbstractClassLoaderValue.computeIfAbsent(AbstractClassLoaderValue.java:205)
	at java.base/java.lang.reflect.Proxy.getProxyConstructor(Proxy.java:426)
	at java.base/java.lang.reflect.Proxy.getProxyClass(Proxy.java:386)
	at org.apache.tomcat.jdbc.pool.ConnectionPool.getProxyConstructor(ConnectionPool.java:370)
	at org.apache.tomcat.jdbc.pool.ConnectionPool.setupConnection(ConnectionPool.java:339)
Comment 1 Mark Thomas 2023-10-10 17:46:56 UTC
Fixed in:
- 11.0.x with 11.0.0-M13 onwards
- 10.1.x with 10.1.15 onwards
- 9.0.x with 9.0.82 onwards
- 8.5.x with 8.5.94 onwards

Until those releases are available, you can use the tomcat-jdbc.jar from the previous release.
Comment 2 tza 2023-10-10 17:55:23 UTC
Thanks for the fast reply!
Comment 3 Konstantin Kolinko 2023-10-10 23:12:58 UTC
(In reply to Mark Thomas from comment #1)
> Fixed in:
> - 8.5.x with 8.5.94 onwards

Correction: The above should be "with 8.5.95 onwards".

(Tomcat 8.5.94 had already been tagged when this issue was fixed.)
Comment 4 Remy Maucherat 2023-10-12 09:21:49 UTC
*** Bug 67697 has been marked as a duplicate of this bug. ***
Comment 5 Remy Maucherat 2023-10-15 19:14:54 UTC
*** Bug 67757 has been marked as a duplicate of this bug. ***