Caleb Lim created KAFKA-7346:
--------------------------------

             Summary: Cannot run Kafka Connect within a web application
                 Key: KAFKA-7346
                 URL: https://issues.apache.org/jira/browse/KAFKA-7346
             Project: Kafka
          Issue Type: Improvement
          Components: KafkaConnect
    Affects Versions: 1.1.1
            Reporter: Caleb Lim


The Plugins class loads plugins using DelegatingClassLoader whose parent class 
loader is Application class loader.

public DelegatingClassLoader(List<String> pluginPaths) {
    this(pluginPaths, ClassLoader.getSystemClassLoader()); //-> Application 
class loader
}

When running Kafka Connect within tomcat web applications, Plugins#pluginClass 
always throws ClassNotFoundException because "pluginClass" is loaded not by 
Application class loader but by ParallelWebAppClassLoader.

protected static Class pluginClass(...){

    Class<?> klass = loader.loadClass(classOrAlias, false);

    if (pluginClass.isAssignableFrom(klass)) {    // -> returns false

        return (Class<? extends U>) klass;

    }

     throw new ClassNotFoundException(...);

}

 

Here is the class loader hierarchy when using JsonConverter:

Converter

    -ParallelWebAppClassLoader

        - URLClassLoader (parent)

            -Launcher$AppClassLoader (parent)

JsonConverter

    -PluginClassLoader

        -DelegatingClassLoader(parent)

            -Launher$AppClassLoader

 

 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to