Uploaded image for project: 'Flink'
  1. Flink
  2. FLINK-26527

ClassCastException in TemporaryClassLoaderContext

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Not A Problem
    • 1.13.5, 1.14.3
    • None
    • None

    Description

      When I try to run sql using flink's classloader, I get the following exception:

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

      my code is like this:

      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");
      } 

      But, if you change `classloader.resolve-order` to `parent-first`, everything works fine

      Attachments

        Activity

          People

            Unassigned Unassigned
            tinny shizhengchao
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: