[
https://issues.apache.org/jira/browse/KAFKA-5953?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16193156#comment-16193156
]
Randall Hauch commented on KAFKA-5953:
--------------------------------------
No, that's not the source of the problem. It has more to do with the timing of
the first code to cause DriverManager to be loaded and initialized, at which
point it attempts to scan for all the Driver classes using the system
classloader. But when JDBC driver JARs are located within a plugin, the
DriverManager only finds their Driver implementation if that plugin happened to
be the first plugin to access DriverManager and/or use JDBC. Debezium's MySQL
connector doesn't have a problem because it directly loads the MySQL Driver
class, which like all Driver implementations registers itself with the
DriverManager.
A possible workaround is to have all the JDBC drivers on the classpath so that
no matter when DriverManager is loaded it will always find the JDBC drivers. Of
course, this is not ideal, which is why [~kkonstantine] is looking into a fix
for this.
> Connect classloader isolation may be broken for JDBC drivers
> ------------------------------------------------------------
>
> Key: KAFKA-5953
> URL: https://issues.apache.org/jira/browse/KAFKA-5953
> Project: Kafka
> Issue Type: Bug
> Components: KafkaConnect
> Affects Versions: 0.11.0.0
> Reporter: Jiri Pechanec
> Priority: Critical
>
> Let's suppose there are two connectors deployed
> # using JDBC driver (Debezium MySQL connector)
> # using PostgreSQL JDBC driver (JDBC sink).
> Connector 1 is started first - it executes a statement
> {code:java}
> Connection conn = DriverManager.getConnection(url, props);
> {code}
> As a result a {{DriverManager}} calls {{ServiceLoader}} and searches for all
> JDBC drivers. The postgres driver from connector 2) is found associated with
> classloader from connector 1).
> Connector 2 is started after that - it executes a statement
> {code:java}
> connection = DriverManager.getConnection(url, username, password);
> {code}
> DriverManager finds the connector that was loaded in step before but becuase
> the classloader is different - now we use classloader 2) so it refuses to
> load the class and no JDBC driver is found.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)