You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@kafka.apache.org by "Caleb Lim (JIRA)" <ji...@apache.org> on 2018/08/26 20:11:00 UTC

[jira] [Created] (KAFKA-7346) Cannot run Kafka Connect within a web application

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)