You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "Martijn Visser (Jira)" <ji...@apache.org> on 2022/03/08 08:06:00 UTC

[jira] [Commented] (FLINK-26527) ClassCastException in TemporaryClassLoaderContext

    [ https://issues.apache.org/jira/browse/FLINK-26527?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17502784#comment-17502784 ] 

Martijn Visser commented on FLINK-26527:
----------------------------------------

[~tinny] You're suffering from the problem which is explained on the Debugging Classloading documentation, see https://nightlies.apache.org/flink/flink-docs-master/docs/ops/debugging/debugging_classloading/#x-cannot-be-cast-to-x-exceptions

Could you check if this is indeed your problem?

> 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)