ding bei
02/24/2023, 4:14 AM1. My APP is runing on kubernetes managed by flink kubernetes operator, I use ENV ENABLE_BUILT_IN_PLUGINS to link hadoop-s3 plugin to where it supposed to be, and I exec into the pod ,confirmed iflink-s3-fs-hadoop-1.15.2.jar is in plugins/hadoop-s3 folder.
2. My APP will read proto records from kafka, so I wrote a deserializer which will call hadoop releated class funciton ,but not directly ,in a very deep chain.
3. However , it report NoClassFoundError org/apache/hadoop/conf/Configuration ,and the error trace back to deserializer
4. Then I append hadoop dependency into my application pom ,and package into a fat jar, guess what, it worked
So can somebody please explain this to me ? I read a lot of times of Flink DOC about plugins and classloader ,still no clueMartijn Visser
02/24/2023, 1:50 PMhadoop-s3-plugin is stricly for connecting to S3; it doesn't provide you with Hadoop on your classpath. See https://nightlies.apache.org/flink/flink-docs-master/docs/dev/configuration/advanced/#hadoop-dependencies on how to use Flink with Hadoopding bei
02/25/2023, 6:07 PMthere is a hierarchy of typically two ClassLoaders: (1) Java's _application classloader_, (2) the dynamic _plugin/user code classloader_.The dynamic ClassLoader has the application classloader as its parent.And plugin classloader is dedicated per plugin. By default, Flink inverts classloading order, child first then parent. But there are exceptions, org.apache.hadoop is one of them. So for example, when I sink files into S3 which will use classes in org.apache.hadoop. In order to do that , I have to copy hadoop-s3 jar into plugins/hadoop-s3 package . Right now ,there are only one hadoop jar in my environment. So when the app starts, The parent classloader will first look into classpath , and find no hadoop jar there. Then it will call its child classloader. The question is which class loader will it call, the user code dynamic classloader or the hadoop-s3 plugin dynamic classloader? sure its the latter one, but how does he konw? what if I also package hadoop jar into my app jar as a fat jar. what will happen then?Martijn Visser
02/25/2023, 6:14 PMding bei
02/26/2023, 2:21 AM