-
Enhancement
-
Resolution: Done
-
Minor
-
None
When the Embedded Engine is used inside a SpringBoot application that is packed as a nested jar (see https://docs.spring.io/spring-boot/specification/executable-jar/nested-jars.html), the ClassLoader in the submitted thread must be set to the Spring ClassLoader before starting the engine, otherwise the dynamic class loading won't work.
See a discussion here: https://debezium.zulipchat.com/#narrow/channel/348249-community-postgresql/topic/Unable.20to.20find.20class.20io.2Edebezium.2Econnector.2Epostgresql.2EPostgr/near/535534861
So something like this:
final ClassLoader springClassLoader = Thread.currentThread().getContextClassLoader(); DebeziumEngine<ChangeEvent<String, String>> engine = createEngine(...); executor.submit(() -> { final ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(springClassLoader); engine.run(); } finally { Thread.currentThread().setContextClassLoader(originalClassLoader); } });