Hi,
我在使用flink-1.13的过程中,尝试使用kafka数据源。 我把flink-example中的stream-WordCount进行了修改,使其从本地kafka读取数据,直接砸idea运行也结果良好,可以正常运行。但是使用mvn打包后的jar直接提交给本地编译的flink binary(本地启动的standlone flink),会报以下异常。 java.lang.RuntimeException: Could not look up the main(String[]) method from the class org.apache.flink.streaming.examples.wordcount.WordCount2: org/apache/flink/stream ing/connectors/kafka/KafkaDeserializationSchema at org.apache.flink.client.program.PackagedProgram.hasMainMethod(PackagedProgram.java:315) at org.apache.flink.client.program.PackagedProgram.(PackagedProgram.java:161) at org.apache.flink.client.program.PackagedProgram.(PackagedProgram.java:65) at org.apache.flink.client.program.PackagedProgram$Builder.build(PackagedProgram.java:691) at org.apache.flink.client.cli.CliFrontend.buildProgram(CliFrontend.java:851) at org.apache.flink.client.cli.CliFrontend.getPackagedProgram(CliFrontend.java:271) at org.apache.flink.client.cli.CliFrontend.run(CliFrontend.java:245) at org.apache.flink.client.cli.CliFrontend.parseAndRun(CliFrontend.java:1054) at org.apache.flink.client.cli.CliFrontend.lambda$main$10(CliFrontend.java:1132) at org.apache.flink.runtime.security.contexts.NoOpSecurityContext.runSecured(NoOpSecurityContext.java:28) at org.apache.flink.client.cli.CliFrontend.main(CliFrontend.java:1132) Caused by: java.lang.NoClassDefFoundError: org/apache/flink/streaming/connectors/kafka/KafkaDeserializationSchema at java.lang.Class.getDeclaredMethods0(Native Method) at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) at java.lang.Class.privateGetMethodRecursive(Class.java:3048) at java.lang.Class.getMethod0(Class.java:3018) at java.lang.Class.getMethod(Class.java:1784) at org.apache.flink.client.program.PackagedProgram.hasMainMethod(PackagedProgram.java:307) ... 10 more Caused by: java.lang.ClassNotFoundException: org.apache.flink.streaming.connectors.kafka.KafkaDeserializationSchema at java.net.URLClassLoader.findClass(URLClassLoader.java:382) at java.lang.ClassLoader.loadClass(ClassLoader.java:418) at org.apache.flink.util.FlinkUserCodeClassLoader.loadClassWithoutExceptionHandling(FlinkUserCodeClassLoader.java:64) at org.apache.flink.util.ChildFirstClassLoader.loadClassWithoutExceptionHandling(ChildFirstClassLoader.java:65) at org.apache.flink.util.FlinkUserCodeClassLoader.loadClass(FlinkUserCodeClassLoader.java:48) at java.lang.ClassLoader.loadClass(ClassLoader.java:351) ... 16 more 我查询的解决方式是在pom中改变对应的依赖,但是我不理解该如何处理,我在flink-example-stream的pom文件中找到了对于kafka-connector的依赖,上层的pom文件没有相关的依赖,请问我该如何处理这一问题? 我可以保证的是pim文件只有对于新增示例项目的修改,没有修改其他的依赖关系 非常感谢! |
Hi,
从错误来看是在作业 JAR 里面缺少了 Flink Kafka connector 相关的类。可以确认一下 JAR 包里面是否把 Flink Kafka connector 相关的类打进去了,在 Maven POM 依赖中引用了 Kafka connector 并不意味着一定会被打进作业 JAR 中。 -- Best Regards, Qingsheng Ren Real-time Computing Department, Alibaba Cloud Alibaba Group Email: [hidden email] 在 2021年4月7日 +0800 PM3:27,小猫爱吃鱼 <[hidden email]>,写道: > Hi, > 我在使用flink-1.13的过程中,尝试使用kafka数据源。 > 我把flink-example中的stream-WordCount进行了修改,使其从本地kafka读取数据,直接砸idea运行也结果良好,可以正常运行。但是使用mvn打包后的jar直接提交给本地编译的flink binary(本地启动的standlone flink),会报以下异常。 > > > java.lang.RuntimeException: Could not look up the main(String[]) method from the class org.apache.flink.streaming.examples.wordcount.WordCount2: org/apache/flink/stream > ing/connectors/kafka/KafkaDeserializationSchema > at org.apache.flink.client.program.PackagedProgram.hasMainMethod(PackagedProgram.java:315) > at org.apache.flink.client.program.PackagedProgram.(PackagedProgram.java:161) > at org.apache.flink.client.program.PackagedProgram.(PackagedProgram.java:65) > at org.apache.flink.client.program.PackagedProgram$Builder.build(PackagedProgram.java:691) > at org.apache.flink.client.cli.CliFrontend.buildProgram(CliFrontend.java:851) > at org.apache.flink.client.cli.CliFrontend.getPackagedProgram(CliFrontend.java:271) > at org.apache.flink.client.cli.CliFrontend.run(CliFrontend.java:245) > at org.apache.flink.client.cli.CliFrontend.parseAndRun(CliFrontend.java:1054) > at org.apache.flink.client.cli.CliFrontend.lambda$main$10(CliFrontend.java:1132) > at org.apache.flink.runtime.security.contexts.NoOpSecurityContext.runSecured(NoOpSecurityContext.java:28) > at org.apache.flink.client.cli.CliFrontend.main(CliFrontend.java:1132) > Caused by: java.lang.NoClassDefFoundError: org/apache/flink/streaming/connectors/kafka/KafkaDeserializationSchema > at java.lang.Class.getDeclaredMethods0(Native Method) > at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) > at java.lang.Class.privateGetMethodRecursive(Class.java:3048) > at java.lang.Class.getMethod0(Class.java:3018) > at java.lang.Class.getMethod(Class.java:1784) > at org.apache.flink.client.program.PackagedProgram.hasMainMethod(PackagedProgram.java:307) > ... 10 more > Caused by: java.lang.ClassNotFoundException: org.apache.flink.streaming.connectors.kafka.KafkaDeserializationSchema > at java.net.URLClassLoader.findClass(URLClassLoader.java:382) > at java.lang.ClassLoader.loadClass(ClassLoader.java:418) > at org.apache.flink.util.FlinkUserCodeClassLoader.loadClassWithoutExceptionHandling(FlinkUserCodeClassLoader.java:64) > at org.apache.flink.util.ChildFirstClassLoader.loadClassWithoutExceptionHandling(ChildFirstClassLoader.java:65) > at org.apache.flink.util.FlinkUserCodeClassLoader.loadClass(FlinkUserCodeClassLoader.java:48) > at java.lang.ClassLoader.loadClass(ClassLoader.java:351) > ... 16 more > > > 我查询的解决方式是在pom中改变对应的依赖,但是我不理解该如何处理,我在flink-example-stream的pom文件中找到了对于kafka-connector的依赖,上层的pom文件没有相关的依赖,请问我该如何处理这一问题? > 我可以保证的是pim文件只有对于新增示例项目的修改,没有修改其他的依赖关系 > > > 非常感谢! |
Free forum by Nabble | Edit this page |