[ https://issues.apache.org/jira/browse/FLINK-26527?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
shizhengchao updated FLINK-26527: --------------------------------- Description: When I try to run sql using flink's classloader, I get the following exception: {code:java} Exception in thread "main" java.lang.ClassCastException: org.codehaus.janino.CompilerFactory cannot be cast to org.codehaus.commons.compiler.ICompilerFactory at org.codehaus.commons.compiler.CompilerFactoryFactory.getCompilerFactory(CompilerFactoryFactory.java:129) ……{code} my code is like this: {code:java} Configuration configuration = new Configuration(); configuration.set(CoreOptions.CLASSLOADER_RESOLVE_ORDER, "child-first"); List<URL> dependencies = FlinkClassLoader.getFlinkDependencies(FLINK_HOME/lib); URLClassLoader classLoader = ClientUtils.buildUserCodeClassLoader( dependencies, Collections.emptyList(), SessionContext.class.getClassLoader(), configuration); try (TemporaryClassLoaderContext ignored = TemporaryClassLoaderContext.of(classLoader)) { tableEnv.explainSql(sql); //CompilerFactoryFactory.getCompilerFactory("org.codehaus.janino.CompilerFactory"); } {code} But, if you change `classloader.resolve-order` to `parent-first`, everything works fine was: When I try to run sql using flink's classloader, I get the following exception: {code:java} Exception in thread "main" java.lang.ClassCastException: org.codehaus.janino.CompilerFactory cannot be cast to org.codehaus.commons.compiler.ICompilerFactory at org.codehaus.commons.compiler.CompilerFactoryFactory.getCompilerFactory(CompilerFactoryFactory.java:129) ……{code} my code is like this: {code:java} Configuration configuration = new Configuration(); configuration.set(CoreOptions.CLASSLOADER_RESOLVE_ORDER, "child-first"); List<URL> dependencies = FlinkClassLoader.getFlinkDependencies( {code} {color:#000091}${FLINK_HOME}/lib{color} {code:java} ); URLClassLoader classLoader = ClientUtils.buildUserCodeClassLoader( dependencies, Collections.emptyList(), SessionContext.class.getClassLoader(), configuration); try (TemporaryClassLoaderContext ignored = TemporaryClassLoaderContext.of(classLoader)) { tableEnv.explainSql(sql); //CompilerFactoryFactory.getCompilerFactory("org.codehaus.janino.CompilerFactory"); } {code} But, if you change `classloader.resolve-order` to `parent-first`, everything works fine > ClassCastException in TemporaryClassLoaderContext > ------------------------------------------------- > > Key: FLINK-26527 > URL: https://issues.apache.org/jira/browse/FLINK-26527 > Project: Flink > Issue Type: Bug > Components: Client / Job Submission > Affects Versions: 1.13.5, 1.14.3 > Reporter: shizhengchao > Priority: Major > > When I try to run sql using flink's classloader, I get the following > exception: > {code:java} > Exception in thread "main" java.lang.ClassCastException: > org.codehaus.janino.CompilerFactory cannot be cast to > org.codehaus.commons.compiler.ICompilerFactory > at > org.codehaus.commons.compiler.CompilerFactoryFactory.getCompilerFactory(CompilerFactoryFactory.java:129) > > ……{code} > my code is like this: > {code:java} > Configuration configuration = new Configuration(); > configuration.set(CoreOptions.CLASSLOADER_RESOLVE_ORDER, "child-first"); > List<URL> dependencies = > FlinkClassLoader.getFlinkDependencies(FLINK_HOME/lib); > URLClassLoader classLoader = ClientUtils.buildUserCodeClassLoader( > dependencies, > Collections.emptyList(), > SessionContext.class.getClassLoader(), > configuration); > try (TemporaryClassLoaderContext ignored = > TemporaryClassLoaderContext.of(classLoader)) { > tableEnv.explainSql(sql); > > //CompilerFactoryFactory.getCompilerFactory("org.codehaus.janino.CompilerFactory"); > } {code} > But, if you change `classloader.resolve-order` to `parent-first`, everything > works fine -- This message was sent by Atlassian Jira (v8.20.1#820001)