Uploaded image for project: 'Debezium'
  1. Debezium
  2. DBZ-4025

Embedded engine class loader cannot be used to load the JDBC driver

    XMLWordPrintable

Details

    • Enhancement
    • Resolution: Unresolved
    • Minor
    • Backlog
    • 1.7.0.CR1
    • embedded-engine
    • None
    • False
    • False

    Description

      Hello, first of all I'd like to thank the Debezium team for your effort. Debezium is absolutely fantastic and is an amazing fit for our project. Looking forward to potentially contributing as well.

      Our use case is a little bit curious: I don't have a JDBC driver that's available via the system classpath but instead, I can only load it via a URLClassLoader. When creating a new embedded engine via 

      DebeziumEngine::create

      there is an option to supply a classloader which, as per my understanding, is used to load some of the components like the offset backing stores. I was under the impression that it is can also be used for class loading the JDBC driver (i.e. 'org.postgresql.Driver`) but when I pass that classloader into the engine I get the following exception still:

       

      java.lang.NoClassDefFoundError: org/postgresql/Driverjava.lang.NoClassDefFoundError: org/postgresql/Driver 
      at io.debezium.connector.postgresql.connection.PostgresConnection.<clinit>(PostgresConnection.java:63) ~[debezium-connector-postgres-1.7.0.CR1.jar:1.7.0.CR1] 
      at io.debezium.connector.postgresql.PostgresConnectorTask.start(PostgresConnectorTask.java:75) ~[debezium-connector-postgres-1.7.0.CR1.jar:1.7.0.CR1] 
      at io.debezium.connector.common.BaseSourceTask.start(BaseSourceTask.java:133) ~[debezium-core-1.7.0.CR1.jar:1.7.0.CR1] 
      at io.debezium.embedded.EmbeddedEngine.run(EmbeddedEngine.java:759) ~[debezium-embedded-1.7.0.CR1.jar:1.7.0.CR1] 
      at io.debezium.embedded.ConvertingEngineBuilder$2.run(ConvertingEngineBuilder.java:188) ~[debezium-embedded-1.7.0.CR1.jar:1.7.0.CR1] 
      at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[na:na] 
      at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[na:na] 
      
      at java.base/java.lang.Thread.run(Thread.java:829) ~[na:na]Caused by: java.lang.ClassNotFoundException: org.postgresql.Driver 
      at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581) ~[na:na] 
      at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) ~[na:na] 
      at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522) ~[na:na]
      

       

      My guess is that this is due to the different class loading semantics and that the static variable FACTORY within PostgresConnection is not using the supplied class loader. Using a custom thread factory for the executor with the modified class loader as the thread's context class loader doesn't work either.

      I was wondering if it would be possible to modify the flow so that the JDBC classes would also be loaded from the supplied class loader. Thank you!

      Attachments

        Activity

          People

            Unassigned Unassigned
            mark.bereznitsky Mark Bereznitsky (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: