Hi, It should work if you set TCCL (ThreadContextClassLoader) before Class.getDeclaredConstructor().newInstance(). If you set the TCCL to the bundle classloader, it should work I think.
Regards JB On Mon, Mar 28, 2022 at 9:36 AM Daniel Las <daniel....@empirica.io> wrote: > > HI JB, > > I tried to start my application using original ServiceMix Kafka Clients and > Kafka Stream bundles. > > The problem is in the way Kafka Clients library handles configuration. You > need to pass the class name and the Kafka client creates the instance via > Class.getDeclaredConstructor().newInstance(). This is what is happens with > Kafka Streams, it passes class name and Kafka Clients fails because it can't > find the class. > > I went through the Kafka libs source code and found that it uses context > class loader if present. The issues are gone for now after setting my bundle > class loader as context class loader. > > Regards > > > > sob., 26 mar 2022 o 07:30 Jean-Baptiste Onofré <j...@nanthrax.net> napisał(a): >> >> Hi Daniel, >> >> Generally speaking, a solution that always works is to create your >> bundle with private packages/ship all kafka packages (general comment >> in OSGi/Karaf). >> >> If you want to use the import package approach, the ServiceMix bundles >> should work (I didn't try recently, but I tried while ago). >> >> About your error, I checked and LogAndFailExceptionHandler class is >> present in the kafka-streams bundle. >> >> Do you have the import in your bundle (as I guess the >> kafka.common.Config is in your bundle classloader, so looking for >> LogAndFailExceptionHandler class in the same classloader) ? >> >> Regards >> JB >> >> On Sat, Mar 26, 2022 at 7:01 AM Daniel Las <daniel....@empirica.io> wrote: >> > >> > Hi, >> > >> > Did anybody manage to start Kafka streams application in Karaf? I tried >> > different approaches: >> > >> > * use ServiceMix kafka-clients and kafka-streams bundles (2.8.1_1) >> > * repackage kafka-streams and make it a fragment for kafka-clients >> > * shade my bundle with kafka-clients and kafka-streams included >> > >> > and every time fail with a class loading issue related to default >> > configuration template built inside kafka-streams, specifically: >> > >> > Caused by: org.apache.kafka.common.config.ConfigException: Invalid value >> > org.apache.kafka.streams.errors.LogAndFailExceptionHandler for >> > configuration default.deserialization.exception.handler: Class >> > org.apache.kafka.streams.errors.LogAndFailExceptionHandler could not be >> > found. >> > >> > Best regards >> > >> > -- >> > Daniel Łaś >> > > > > > -- > Daniel Łaś