Flink设置加载jar顺序
以下异常信息
org.apache.flink.client.program.ProgramInvocationException: The main method caused an error: Unable to instantiate java compiler
...
Caused by: java.lang.IllegalStateException: Unable to instantiate java compiler
...
Caused by: java.lang.ClassCastException: org.codehaus.janino.CompilerFactory cannot be cast to org.codehaus.commons.compiler.ICompilerFactory
分析原因:执行Jar包中的依赖与集群中存在依赖冲突
解决办法,配置类加载顺序
flink-conf.yaml如下配置
classloader.resolve-order: parent-first
parent-first
优先从Flink集群加载类,如果没有该类,就从用户提交的任务(jar包)中加载
child-first (默认)
优先从Flink任务(jar包)加载类,如果没有,则从Flink集群加载