Flink Error: java.lang.ClassNotFoundException: org.apache.flink.shaded.calcite.com.google.common.base.Throwables

4.7k views Asked by At

I am using Flink for streaming the data which is in the csv file. I want to put it into table format with certain schema. For this purpose I am using Flink-table_2.10-1.1.3.jar (Table api) but I got the errors:

log4j:WARN No appenders could be found for logger (org.apache.flink.api.java.typeutils.TypeExtractor).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/flink/shaded/calcite/com/google/common/base/Throwables
    at org.apache.calcite.rel.metadata.JaninoRelMetadataProvider.create(JaninoRelMetadataProvider.java:450)
    at org.apache.calcite.rel.metadata.JaninoRelMetadataProvider.revise(JaninoRelMetadataProvider.java:460)
    at org.apache.calcite.rel.metadata.RelMetadataQuery.revise(RelMetadataQuery.java:186)
    at org.apache.calcite.rel.metadata.RelMetadataQuery.collations(RelMetadataQuery.java:484)
    at org.apache.calcite.rel.metadata.RelMdCollation.project(RelMdCollation.java:207)
    at org.apache.calcite.rel.logical.LogicalProject$1.get(LogicalProject.java:122)
    at org.apache.calcite.rel.logical.LogicalProject$1.get(LogicalProject.java:120)
    at org.apache.calcite.plan.RelTraitSet.replaceIfs(RelTraitSet.java:238)
    at org.apache.calcite.rel.logical.LogicalProject.create(LogicalProject.java:116)
    at org.apache.calcite.rel.logical.LogicalProject.create(LogicalProject.java:108)
    at org.apache.flink.api.table.plan.logical.Project.construct(operators.scala:90)
    at org.apache.flink.api.table.plan.logical.Project.construct(operators.scala:85)
    at org.apache.flink.api.table.plan.logical.LogicalNode.toRelNode(LogicalNode.scala:78)
    at org.apache.flink.api.table.Table.getRelNode(table.scala:66)
    at org.apache.flink.api.table.StreamTableEnvironment.translate(StreamTableEnvironment.scala:243)
    at org.apache.flink.api.java.table.StreamTableEnvironment.toDataStream(StreamTableEnvironment.scala:147)
    at table_streaming_test.main(table_streaming_test.java:90)
Caused by: java.lang.ClassNotFoundException: org.apache.flink.shaded.calcite.com.google.common.base.Throwables
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 17 more

When I explore the corresponding jar, the respective class is present there. Can you please tell that why this is happening?

Also can I get the maven source so that I can build the Flink-table .jar at my place?

2

There are 2 answers

2
Sina Nourian On

I had the same problem with CEP library. I added to my pom file but I kept getting ClassNotFoundException. I even packaged it with my jar file via IntelliJ but didn't work.

  1. If you're using their flink-quickstart archetype, I think there are some other things to change in pom file to make it work. When I created a clean project and added flink dependencies myself, I didn't get that exception anymore. You can try and see if this approach works.

  2. You can also add flink-table JAR file to lib folder in Flink. this also fixed my problem with CEP library. the JAR file is available in Maven repository website. download the version you want.

According to the Table and SQL document on Flink website:

Note: The Table API is currently not part of the binary distribution. See linking with it for cluster execution here.

0
user_19 On

I was also facing the same problem with Table api in flink v1.4.2.

I added flink-table_2.11-1.4.2.jar file present in opt folder to the lib folder and restarted flink. This works for me. Hopefully works for you too :)