Rion Williams
10/26/2023, 1:30 PMjava.lang.ClassCastException: org.codehaus.janino.CompilerFactory cannot be cast to org.codehaus.commons.compiler.ICompilerFactory
I have a job that using both the streaming and table APIs similar to the Immerok Table Deduplication example, however the job seems to fail once it starts actually doing anything Table API related. I have I believe all of the appropriate references and I’ve tried several attempts at explicitly removing the conflicting bits (as they would be included in the compiled jar already):
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-api-java-bridge</artifactId>
<version>${flink.version}</version>
<scope>${flink.scope}</scope>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-planner-loader</artifactId>
<version>${flink.version}</version>
<scope>${flink.scope}</scope>
<exclusions>
<exclusion>
<artifactId>*</artifactId>
<groupId>org.codehaus.janino</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-runtime</artifactId>
<version>${flink.version}</version>
<scope>${flink.scope}</scope>
<exclusions>
<exclusion>
<artifactId>*</artifactId>
<groupId>org.codehaus.janino</groupId>
</exclusion>
</exclusions>
</dependency>
I’ve tried several variations of this - any ideas would be welcome as it only seems to be a runtime issue (but I can’t reproduce it in an IDE).Martijn Visser
10/26/2023, 1:31 PMMartijn Visser
10/26/2023, 1:31 PMRion Williams
10/26/2023, 1:33 PMRion Williams
10/26/2023, 1:34 PMflink-clients dependency seems to bring in a commons-cli:commons-cli - maybe that’s related?Rion Williams
10/26/2023, 1:35 PMSergey Nuyanzin
10/26/2023, 1:40 PMmvn dependency:tree | grep janino ?Rion Williams
10/26/2023, 1:41 PMRion Williams
10/26/2023, 3:17 PMdependency:tree to Janino anywhere.Sergey Nuyanzin
10/26/2023, 3:20 PMRion Williams
10/26/2023, 3:33 PMRion Williams
10/26/2023, 3:33 PMRion Williams
10/26/2023, 3:34 PMRion Williams
10/26/2023, 3:34 PMRion Williams
10/26/2023, 3:35 PMRion Williams
10/26/2023, 3:39 PMSergey Nuyanzin
10/26/2023, 3:40 PMRion Williams
10/26/2023, 3:40 PMRion Williams
10/26/2023, 3:41 PMSergey Nuyanzin
10/26/2023, 3:41 PMRion Williams
10/26/2023, 3:42 PMRion Williams
10/26/2023, 3:42 PMSergey Nuyanzin
10/26/2023, 3:43 PMSergey Nuyanzin
10/26/2023, 3:43 PMSergey Nuyanzin
10/26/2023, 3:44 PMRion Williams
10/26/2023, 3:44 PMSergey Nuyanzin
10/26/2023, 3:45 PMRion Williams
10/26/2023, 3:45 PMRion Williams
10/26/2023, 3:45 PMRion Williams
10/26/2023, 3:46 PMRion Williams
10/26/2023, 3:47 PM<artifactSet>
<excludes>
<exclude>org.apache.flink:flink-shaded-force-shading</exclude>
<exclude>com.google.code.findbugs:jsr305</exclude>
<exclude>org.slf4j:*</exclude>
<exclude>org.apache.logging.log4j:*</exclude>
</excludes>
</artifactSet>Sergey Nuyanzin
10/26/2023, 3:48 PMRion Williams
10/26/2023, 5:01 PMorg.codehaus.* however ended up getting the same exception.Rion Williams
10/26/2023, 5:07 PMRion Williams
10/26/2023, 5:10 PMApplication failed unexpectedly: java.util.concurrent.CompletionException: org.apache.flink.client.deployment.application.ApplicationExecutionException: Could not execute application.
at java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:292) ~[?:1.8.0_345]
at java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:308) ~[?:1.8.0_345]
at java.util.concurrent.CompletableFuture.uniCompose(CompletableFuture.java:957) ~[?:1.8.0_345]
at java.util.concurrent.CompletableFuture$UniCompose.tryFire(CompletableFuture.java:940) ~[?:1.8.0_345]
at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:488) ~[?:1.8.0_345]
at java.util.concurrent.CompletableFuture.completeExceptionally(CompletableFuture.java:1990) ~[?:1.8.0_345]
...
Caused by: org.apache.flink.client.program.ProgramInvocationException: The main method caused an error: Unable to instantiate java compiler
at org.apache.flink.client.program.PackagedProgram.callMainMethod(PackagedProgram.java:372) ~[flink-dist-1.15.2-stream3.jar:1.15.2-stream3]
...
Caused by: java.lang.IllegalStateException: Unable to instantiate java compiler
at org.apache.calcite.rel.metadata.JaninoRelMetadataProvider.compile(JaninoRelMetadataProvider.java:428) ~[?:?]
...
Caused by: 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) ~[flink-table-runtime-1.15.2-stream3.jar:1.15.2-stream3]
...Rion Williams
10/26/2023, 5:11 PMMartijn Visser
10/26/2023, 5:12 PMRion Williams
10/26/2023, 5:14 PM/flink/lib/log4j-layout-template-json-2.17.1.jarRion Williams
10/26/2023, 5:15 PMRion Williams
10/26/2023, 5:16 PM<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-streaming-java</artifactId>
<version>${flink.version}</version>
<scope>${flink.scope}</scope>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-clients</artifactId>
<version>${flink.version}</version>
<scope>${flink.scope}</scope>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-api-java-bridge</artifactId>
<version>${flink.version}</version>
<scope>${flink.scope}</scope>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-planner-loader</artifactId>
<version>${flink.version}</version>
<scope>${flink.scope}</scope>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-runtime</artifactId>
<version>${flink.version}</version>
<scope>${flink.scope}</scope>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-connector-kafka</artifactId>
<version>${flink.version}</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-connector-base</artifactId>
<version>${flink.version}</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-json</artifactId>
<version>${flink.version}</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-connector-elasticsearch7</artifactId>
<version>${flink.version}</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-avro-confluent-registry</artifactId>
<version>${flink.version}</version>
</dependency>Martijn Visser
10/26/2023, 5:16 PMRion Williams
10/26/2023, 5:17 PMmvn -T 1C -e install -Dflink.scope=provided -BRion Williams
10/27/2023, 3:20 PM1.15.2-stream3-scala_2.12-java8 image, which has previously worked as expected however the project was recently moved to a different directory with a parent pom and cleaned up, the only major changes were migrating from the following dependencies:
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-java</artifactId>
<version>${flink.version}</version>
<scope>${flink.scope}</scope>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-streaming-java</artifactId>
<version>${flink.version}</version>
<scope>${flink.scope}</scope>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-clients</artifactId>
<version>${flink.version}</version>
<scope>${flink.scope}</scope>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-api-java-bridge</artifactId>
<version>${flink.version}</version>
<scope>${flink.scope}</scope>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-planner_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
<scope>${flink.scope}</scope>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-streaming-scala_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
<scope>${flink.scope}</scope>
</dependency>
to the dependencies that were shared above (non explicit Scala versioned ones). I’m unsure if some of the newer ones need to be explicitly declared as compile scope or if there’s another issue at play.Rion Williams
10/27/2023, 3:31 PMRion Williams
10/27/2023, 6:49 PMCaused by: java.lang.ClassCastException: class org.codehaus.janino.CompilerFactory cannot be cast to class org.codehaus.commons.compiler.ICompilerFactory (org.codehaus.janino.CompilerFactory is in unnamed module of loader org.apache.flink.util.ChildFirstClassLoader @6dab9b6d; org.codehaus.commons.compiler.ICompilerFactory is in unnamed module of loader 'app')Sergey Nuyanzin
10/27/2023, 6:51 PMRion Williams
10/27/2023, 6:53 PM<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-java</artifactId>
<version>${flink.version}</version>
<scope>${flink.scope}</scope>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-streaming-java</artifactId>
<version>${flink.version}</version>
<scope>${flink.scope}</scope>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-clients</artifactId>
<version>${flink.version}</version>
<scope>${flink.scope}</scope>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-api-java-bridge</artifactId>
<version>${flink.version}</version>
<scope>${flink.scope}</scope>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-planner_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
<scope>${flink.scope}</scope>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-streaming-scala_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
<scope>${flink.scope}</scope>
</dependency>
And it was explicitly targeting 1.8 in the `maven-compiler-plugin`:
<configuration>
<source>${target.java.version}</source>
<target>${target.java.version}</target>
</configuration>Rion Williams
10/27/2023, 6:55 PM-java11 variant instead of the -java8 one, updated all of the dependencies to match those defined earlier and in the Immerok Table API example, but have continually fought this error on any attempts to run against 11.Sergey Nuyanzin
10/27/2023, 6:57 PM<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-planner_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
<scope>${flink.scope}</scope>
</dependency>
this module should bring the correct janino dependencySergey Nuyanzin
10/27/2023, 6:58 PMSergey Nuyanzin
10/27/2023, 6:59 PMRion Williams
10/27/2023, 7:03 PMflink-table-planner-loader one bring in janino as well? If so maybe that’s the issue and it should be explicitly compile scoped (as flink.scope is replaced during the build to provided)Rion Williams
10/27/2023, 8:15 PMCaused by: org.apache.flink.client.program.ProgramInvocationException: The main method caused an error: Could not instantiate the executor. Make sure a planner module is on the classpath
...
Caused by: org.apache.flink.table.api.ValidationException: Multiple factories for identifier 'default' that implement 'org.apache.flink.table.delegation.ExecutorFactory' found in the classpath.
Ambiguous factory classes are:
org.apache.flink.table.planner.delegation.DefaultExecutorFactory
org.apache.flink.table.planner.loader.DelegateExecutorFactoryRion Williams
10/27/2023, 8:16 PM<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-streaming-java</artifactId>
<version>${flink.version}</version>
<scope>${flink.scope}</scope>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-java</artifactId>
<version>${flink.version}</version>
<scope>${flink.scope}</scope>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-clients</artifactId>
<version>${flink.version}</version>
<scope>${flink.scope}</scope>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-api-java-bridge</artifactId>
<version>${flink.version}</version>
<scope>${flink.scope}</scope>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-planner_2.12</artifactId>
<version>${flink.version}</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-runtime</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.flink</groupId>
<artifactId>flink-scala_2.12</artifactId>
</exclusion>
</exclusions>
</dependency>Rion Williams
10/27/2023, 8:16 PMRion Williams
10/29/2023, 3:57 AMRion Williams
10/30/2023, 3:09 PM<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-streaming-java</artifactId>
<version>${flink.version}</version>
<scope>${flink.scope}</scope>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-clients</artifactId>
<version>${flink.version}</version>
<scope>${flink.scope}</scope>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-api-java-bridge</artifactId>
<version>${flink.version}</version>
<scope>${flink.scope}</scope>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-planner-loader</artifactId>
<version>${flink.version}</version>
<scope>${flink.scope}</scope>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-runtime</artifactId>
<version>${flink.version}</version>
<scope>${flink.scope}</scope>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-connector-kafka</artifactId>
<version>${flink.version}</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-connector-base</artifactId>
<version>${flink.version}</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-json</artifactId>
<version>${flink.version}</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-connector-elasticsearch7</artifactId>
<version>${flink.version}</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-avro-confluent-registry</artifactId>
<version>${flink.version}</version>
</dependency>
And all of the instances of flink.scope are replaced with provided when building the jars (they use compile for running/testing in the IDE). As mentioned before the image being used behind the scenes would be Ververica Platform’s v2.8 (1.15.2-stream4-scala_2.12-java8). But based on the error message that I’m seeing in the logs, it looks like it’s referencing the table-api-uber jar behind the scenes:
Caused by: 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) ~[flink-table-runtime-1.15.2-stream3.jar:1.15.2-stream3]
at org.codehaus.commons.compiler.CompilerFactoryFactory.getDefaultCompilerFactory(CompilerFactoryFactory.java:79) ~[flink-table-runtime-1.15.2-stream3.jar:1.15.2-stream3]
...
[flink-table-api-java-uber-1.15.2-stream3.jar:1.15.2-stream3]
However, since all of my Flink-related dependencies use provided, I’m not entirely sure how I’d be getting a conflict.Sergey Nuyanzin
10/30/2023, 3:22 PMRion Williams
10/30/2023, 3:37 PM1.15.2-stream4-scala_2.12-java8 and the confusing part is - all of this worked prior to migrating the project over to a separate directory. The only major change was everything in the previous one targeted 1.8 (although still worked against the same image), never previously encountered any of the Janino issues.Rion Williams
10/30/2023, 3:38 PMorg.codehaus.janino.CompilerFactory cannot be cast to org.codehaus.commons.compiler.ICompilerFactory certainly makes it seem as though an extra dependency is in there that shouldn’t be though.Sergey Nuyanzin
10/30/2023, 3:56 PMRion Williams
10/30/2023, 3:59 PMRion Williams
10/31/2023, 2:35 PMclassloader.resolve-order: parent-firstRion Williams
10/31/2023, 2:35 PM