This makes sense, could you file a JIRA to keep track of this? Guozhang
On Mon, Jan 11, 2016 at 8:17 AM, Rajini Sivaram < rajinisiva...@googlemail.com> wrote: > There are multiple places in Kafka where the context class loader or > Class.forName() is used to load classes. Perhaps it would be better to use > a common utility everywhere for dynamic classloading with an option to use > the right classloader.loadClass() that works with OSGi? > > Regards, > > Rajini > > On Mon, Jan 11, 2016 at 1:49 PM, Ramon Gordillo <gordillo.ra...@gmail.com> > wrote: > > > Hi. > > > > I have tried using 0.9.0.0, building an OSGi bundle and exporting the > > packages. However, when creating a Producer, I get an Ex: > > > > Caused by: org.apache.kafka.common.config.ConfigException: Invalid value > > org.apache.kafka.clients.producer.internals.DefaultPartitioner for > > configuration partitioner.class: Class > > org.apache.kafka.clients.producer.internals.DefaultPartitioner could not > be > > found. > > > > at org.apache.kafka.common.config.ConfigDef.parseType(ConfigDef.java:255) > > ~[kafka-clients-0.9.0.0.jar:na] > > at org.apache.kafka.common.config.ConfigDef.define(ConfigDef.java:78) > > ~[kafka-clients-0.9.0.0.jar:na] > > at org.apache.kafka.common.config.ConfigDef.define(ConfigDef.java:94) > > ~[kafka-clients-0.9.0.0.jar:na] > > at org.apache.kafka.clients.producer.ProducerConfig.<clinit>( > > ProducerConfig.java:206) ~[kafka-clients-0.9.0.0.jar:na] > > > > That is because the static ProducerConfig initializer sets the Class name > > and ConfigDef does a Class.forName, which does not work pretty well in > OSGi > > environments. But there is another way to set those "class" parameters, > and > > is using directly the class. So in my OSGi environment, changing > > ProducerConfig: > > > > > > .define(PARTITIONER_CLASS_CONFIG, > > Type.CLASS, > > > DefaultPartitioner.class.getName(), > > Importance.MEDIUM, > > PARTITIONER_CLASS_DOC) > > for > > > > .define(PARTITIONER_CLASS_CONFIG, > > Type.CLASS, > > DefaultPartitioner.class, > > Importance.MEDIUM, > > PARTITIONER_CLASS_DOC) > > > > works fine in OSGi too. > > > > What do you think about this? > > > > Thanks in advance. > > > -- -- Guozhang