Flink Connector打包到服务器报错

【详述】Flink Connector打包到服务器报错image
image

错误信息:
Server Response:
org.apache.flink.runtime.rest.handler.RestHandlerException: Could not execute application. at org.apache.flink.runtime.webmonitor.handlers.JarRunHandler.lambda$handleRequest$1(JarRunHandler.java:108) at java.util.concurrent.CompletableFuture.uniHandle(CompletableFuture.java:822) at java.util.concurrent.CompletableFuture$UniHandle.tryFire(CompletableFuture.java:797) at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:474) at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1595) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Caused by: java.util.concurrent.CompletionException: org.apache.flink.util.FlinkRuntimeException: Could not execute application. at java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:273) at java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:280) at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1592) … 7 more Caused by: org.apache.flink.util.FlinkRuntimeException: Could not execute application. at org.apache.flink.client.deployment.application.DetachedApplicationRunner.tryExecuteJobs(DetachedApplicationRunner.java:88) at org.apache.flink.client.deployment.application.DetachedApplicationRunner.run(DetachedApplicationRunner.java:70) at org.apache.flink.runtime.webmonitor.handlers.JarRunHandler.lambda$handleRequest$0(JarRunHandler.java:102) at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1590) … 7 more Caused by: org.apache.flink.client.program.ProgramInvocationException: The main method caused an error: Unable to create a sink for writing table ‘default_catalog.default_database.StarRocksFootprint’. Table options are: ‘connector’=‘starrocks’ ‘database-name’=‘test’ ‘jdbc-url’=‘jdbc:mysql://tgnet-data001:9030’ ‘load-url’=‘tgnet-data001:8036’ ‘password’=’’ ‘sink.properties.format’=‘json’ ‘sink.properties.strip_outer_array’=‘true’ ‘table-name’=‘Footprint’ ‘username’=‘root’ at org.apache.flink.client.program.PackagedProgram.callMainMethod(PackagedProgram.java:372) at org.apache.flink.client.program.PackagedProgram.invokeInteractiveModeForExecution(PackagedProgram.java:222) at org.apache.flink.client.ClientUtils.executeProgram(ClientUtils.java:114) at org.apache.flink.client.deployment.application.DetachedApplicationRunner.tryExecuteJobs(DetachedApplicationRunner.java:84) … 10 more Caused by: org.apache.flink.table.api.ValidationException: Unable to create a sink for writing table ‘default_catalog.default_database.StarRocksFootprint’. Table options are: ‘connector’=‘starrocks’ ‘database-name’=‘test’ ‘jdbc-url’=‘jdbc:mysql://tgnet-data001:9030’ ‘load-url’=‘tgnet-data001:8036’ ‘password’=’’ ‘sink.properties.format’=‘json’ ‘sink.properties.strip_outer_array’=‘true’ ‘table-name’=‘Footprint’ ‘username’=‘root’ at org.apache.flink.table.factories.FactoryUtil.createTableSink(FactoryUtil.java:171) at org.apache.flink.table.planner.delegation.PlannerBase.getTableSink(PlannerBase.scala:367) at org.apache.flink.table.planner.delegation.PlannerBase.translateToRel(PlannerBase.scala:201) at org.apache.flink.table.planner.delegation.PlannerBase$$anonfun$1.apply(PlannerBase.scala:162) at org.apache.flink.table.planner.delegation.PlannerBase$$anonfun$1.apply(PlannerBase.scala:162) at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234) at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234) at scala.collection.Iterator$class.foreach(Iterator.scala:891) at scala.collection.AbstractIterator.foreach(Iterator.scala:1334) at scala.collection.IterableLike$class.foreach(IterableLike.scala:72) at scala.collection.AbstractIterable.foreach(Iterable.scala:54) at scala.collection.TraversableLike$class.map(TraversableLike.scala:234) at scala.collection.AbstractTraversable.map(Traversable.scala:104) at org.apache.flink.table.planner.delegation.PlannerBase.translate(PlannerBase.scala:162) at org.apache.flink.table.api.internal.TableEnvironmentImpl.translate(TableEnvironmentImpl.java:1518) at org.apache.flink.table.api.internal.TableEnvironmentImpl.executeInternal(TableEnvironmentImpl.java:740) at org.apache.flink.table.api.internal.TableEnvironmentImpl.executeInternal(TableEnvironmentImpl.java:856) at org.apache.flink.table.api.internal.TableEnvironmentImpl.executeSql(TableEnvironmentImpl.java:730) at FootprintInToStarRocks.main(FootprintInToStarRocks.java:58) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.flink.client.program.PackagedProgram.callMainMethod(PackagedProgram.java:355) … 13 more Caused by: org.apache.flink.table.api.ValidationException: Cannot discover a connector using option: ‘connector’=‘starrocks’ at org.apache.flink.table.factories.FactoryUtil.enrichNoMatchingConnectorError(FactoryUtil.java:467) at org.apache.flink.table.factories.FactoryUtil.getDynamicTableFactory(FactoryUtil.java:441) at org.apache.flink.table.factories.FactoryUtil.createTableSink(FactoryUtil.java:167) … 36 more Caused by: org.apache.flink.table.api.ValidationException: Could not find any factory for identifier ‘starrocks’ that implements ‘org.apache.flink.table.factories.DynamicTableFactory’ in the classpath. Available factory identifiers are: blackhole datagen filesystem hbase-2.2 jdbc kafka mysql-cdc print upsert-kafka at org.apache.flink.table.factories.FactoryUtil.discoverFactory(FactoryUtil.java:319) at org.apache.flink.table.factories.FactoryUtil.enrichNoMatchingConnectorError(FactoryUtil.java:463) … 38 more

Flink类加载顺序导致,需要将flink-connector-satarrocks的jar放到flink的lib目录下,并在用户项目中将相关依赖provided。