ParameterTool parameterTool = ParameterTool.fromArgs(args);
Properties kafkaProperties = new Properties();
InputStream inputStream = EventStream.class.getClassLoader().getResourceAsStream(parameterTool.get("properties"));
kafkaProperties.load(inputStream);
String schemaRegistryUrl = parameterTool.getRequired("schema-registry-url");
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
FlinkKafkaConsumer011<HotelsTxnSearchEvent> kafkaConsumer = new FlinkKafkaConsumer011<>(parameterTool.getRequired("topic"), ConfluentRegistryAvroDeserializationSchema.forSpecific(HotelsTxnSearchEvent.class, schemaRegistryUrl), kafkaProperties);
DataStream<HotelsTxnSearchEvent> events = env.addSource(kafkaConsumer);
events.print();
// run the application
env.execute("Sample Run");
例外:
Caused by: org.apache.avro.AvroRuntimeException: avro.shaded.com.google.common.util.concurrent.UncheckedExecutionException: java.lang.NullPointerException
at org.apache.avro.specific.SpecificData.getSchema(SpecificData.java:227)
我的HotelsTxnSearchEvent是使用Java -jar avro-tools-1.7.1.jar编译模式p327.avsc的Avro生成的类。
得到一些人们遇到过相同问题的档案:
http://mail-archives.apache.org/mod_mbox/flink-user/201804.mbox/%3CCAGqa1oKgnzmu_xdvJFnr0wKJpKAXMvhGVgAdSZ7ctFWjJRi2Uw@mail.gmail.com%3E