Hi,

今天又重新测试了一次,日志如下所示:


2022-07-12 13:55:38,674 INFO  org.apache.flink.client.cli.CliFrontend           
           [] - Loading FallbackYarnSessionCli
2022-07-12 13:55:38,707 INFO  org.apache.flink.core.fs.FileSystem               
           [] - Hadoop is not in the classpath/dependencies. The extended set 
of supported File Systems via Hadoop is not available.
2022-07-12 13:55:38,752 INFO  
org.apache.flink.table.client.gateway.context.DefaultContext [] - Executor 
config: {execution.savepoint.ignore-unclaimed-state=false, 
execution.attached=true, execution.savepoint-restore-mode=NO_CLAIM, 
execution.shutdown-on-attached-exit=false, 
pipeline.jars=[file:/home/flink/flink-1.15.1/opt/flink-sql-client-1.15.1.jar, 
file:/home/flink/flink-1.15.1/opt/flink-python_2.12-1.15.1.jar], 
pipeline.classpaths=[], execution.target=remote}
2022-07-12 13:55:40,311 INFO  org.apache.flink.table.client.cli.CliClient       
           [] - Command history file path: /home/flink/.flink-sql-history
2022-07-12 13:55:48,839 WARN  org.apache.flink.table.client.cli.CliClient       
           [] - Could not execute SQL statement.
org.apache.flink.table.client.gateway.SqlExecutionException: Failed to parse 
statement: select * from t1;
at 
org.apache.flink.table.client.gateway.local.LocalExecutor.parseStatement(LocalExecutor.java:174)
 ~[flink-sql-client-1.15.1.jar:1.15.1]
at 
org.apache.flink.table.client.cli.SqlCommandParserImpl.parseCommand(SqlCommandParserImpl.java:45)
 ~[flink-sql-client-1.15.1.jar:1.15.1]
at 
org.apache.flink.table.client.cli.SqlMultiLineParser.parse(SqlMultiLineParser.java:71)
 ~[flink-sql-client-1.15.1.jar:1.15.1]
at org.jline.reader.impl.LineReaderImpl.acceptLine(LineReaderImpl.java:2731) 
~[flink-sql-client-1.15.1.jar:1.15.1]
at org.jline.reader.impl.LineReaderImpl.readLine(LineReaderImpl.java:585) 
~[flink-sql-client-1.15.1.jar:1.15.1]
at 
org.apache.flink.table.client.cli.CliClient.getAndExecuteStatements(CliClient.java:296)
 [flink-sql-client-1.15.1.jar:1.15.1]
at 
org.apache.flink.table.client.cli.CliClient.executeInteractive(CliClient.java:281)
 [flink-sql-client-1.15.1.jar:1.15.1]
at 
org.apache.flink.table.client.cli.CliClient.executeInInteractiveMode(CliClient.java:229)
 [flink-sql-client-1.15.1.jar:1.15.1]
at org.apache.flink.table.client.SqlClient.openCli(SqlClient.java:151) 
[flink-sql-client-1.15.1.jar:1.15.1]
at org.apache.flink.table.client.SqlClient.start(SqlClient.java:95) 
[flink-sql-client-1.15.1.jar:1.15.1]
at org.apache.flink.table.client.SqlClient.startClient(SqlClient.java:187) 
[flink-sql-client-1.15.1.jar:1.15.1]
at org.apache.flink.table.client.SqlClient.main(SqlClient.java:161) 
[flink-sql-client-1.15.1.jar:1.15.1]
Caused by: org.apache.flink.table.api.ValidationException: Unable to create a 
source for reading table 'default_catalog.default_database.t1'.


Table options are:


'connector'='filesystem'
'csv.allow-comments'='true'
'csv.ignore-parse-errors'='true'
'format'='csv'
'path'='/tmp/qwe'
at 
org.apache.flink.table.factories.FactoryUtil.createDynamicTableSource(FactoryUtil.java:159)
 ~[flink-table-api-java-uber-1.15.1.jar:1.15.1]
at 
org.apache.flink.table.factories.FactoryUtil.createDynamicTableSource(FactoryUtil.java:184)
 ~[flink-table-api-java-uber-1.15.1.jar:1.15.1]
at 
org.apache.flink.table.planner.plan.schema.CatalogSourceTable.createDynamicTableSource(CatalogSourceTable.java:175)
 ~[?:?]
at 
org.apache.flink.table.planner.plan.schema.CatalogSourceTable.toRel(CatalogSourceTable.java:115)
 ~[?:?]
at 
org.apache.calcite.sql2rel.SqlToRelConverter.toRel(SqlToRelConverter.java:3585) 
~[?:?]
at 
org.apache.calcite.sql2rel.SqlToRelConverter.convertIdentifier(SqlToRelConverter.java:2507)
 ~[?:?]
at 
org.apache.calcite.sql2rel.SqlToRelConverter.convertFrom(SqlToRelConverter.java:2144)
 ~[?:?]
at 
org.apache.calcite.sql2rel.SqlToRelConverter.convertFrom(SqlToRelConverter.java:2093)
 ~[?:?]
at 
org.apache.calcite.sql2rel.SqlToRelConverter.convertFrom(SqlToRelConverter.java:2050)
 ~[?:?]
at 
org.apache.calcite.sql2rel.SqlToRelConverter.convertSelectImpl(SqlToRelConverter.java:663)
 ~[?:?]
at 
org.apache.calcite.sql2rel.SqlToRelConverter.convertSelect(SqlToRelConverter.java:644)
 ~[?:?]
at 
org.apache.calcite.sql2rel.SqlToRelConverter.convertQueryRecursive(SqlToRelConverter.java:3438)
 ~[?:?]
at 
org.apache.calcite.sql2rel.SqlToRelConverter.convertQuery(SqlToRelConverter.java:570)
 ~[?:?]
at 
org.apache.flink.table.planner.calcite.FlinkPlannerImpl.org$apache$flink$table$planner$calcite$FlinkPlannerImpl$$rel(FlinkPlannerImpl.scala:197)
 ~[?:?]
at 
org.apache.flink.table.planner.calcite.FlinkPlannerImpl.rel(FlinkPlannerImpl.scala:189)
 ~[?:?]
at 
org.apache.flink.table.planner.operations.SqlToOperationConverter.toQueryOperation(SqlToOperationConverter.java:1240)
 ~[?:?]
at 
org.apache.flink.table.planner.operations.SqlToOperationConverter.convertSqlQuery(SqlToOperationConverter.java:1188)
 ~[?:?]
at 
org.apache.flink.table.planner.operations.SqlToOperationConverter.convertValidatedSqlNode(SqlToOperationConverter.java:345)
 ~[?:?]
at 
org.apache.flink.table.planner.operations.SqlToOperationConverter.convert(SqlToOperationConverter.java:238)
 ~[?:?]
at 
org.apache.flink.table.planner.delegation.ParserImpl.parse(ParserImpl.java:105) 
~[?:?]
at 
org.apache.flink.table.client.gateway.local.LocalExecutor.lambda$parseStatement$1(LocalExecutor.java:172)
 ~[flink-sql-client-1.15.1.jar:1.15.1]
at 
org.apache.flink.table.client.gateway.context.ExecutionContext.wrapClassLoader(ExecutionContext.java:88)
 ~[flink-sql-client-1.15.1.jar:1.15.1]
at 
org.apache.flink.table.client.gateway.local.LocalExecutor.parseStatement(LocalExecutor.java:172)
 ~[flink-sql-client-1.15.1.jar:1.15.1]
... 11 more
Caused by: java.lang.NoClassDefFoundError: 
org/apache/flink/table/planner/delegation/ParserFactory
at java.lang.ClassLoader.defineClass1(Native Method) ~[?:1.8.0_311]
at java.lang.ClassLoader.defineClass(ClassLoader.java:756) ~[?:1.8.0_311]
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) 
~[?:1.8.0_311]
at java.net.URLClassLoader.defineClass(URLClassLoader.java:473) ~[?:1.8.0_311]
at java.net.URLClassLoader.access$100(URLClassLoader.java:74) ~[?:1.8.0_311]
at java.net.URLClassLoader$1.run(URLClassLoader.java:369) ~[?:1.8.0_311]
at java.net.URLClassLoader$1.run(URLClassLoader.java:363) ~[?:1.8.0_311]
at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_311]
at java.net.URLClassLoader.findClass(URLClassLoader.java:362) ~[?:1.8.0_311]
at java.lang.ClassLoader.loadClass(ClassLoader.java:418) ~[?:1.8.0_311]
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355) ~[?:1.8.0_311]
at java.lang.ClassLoader.loadClass(ClassLoader.java:405) ~[?:1.8.0_311]
at 
org.apache.flink.util.FlinkUserCodeClassLoader.loadClassWithoutExceptionHandling(FlinkUserCodeClassLoader.java:68)
 ~[flink-dist-1.15.1.jar:1.15.1]
at 
org.apache.flink.util.ChildFirstClassLoader.loadClassWithoutExceptionHandling(ChildFirstClassLoader.java:65)
 ~[flink-dist-1.15.1.jar:1.15.1]
at 
org.apache.flink.util.FlinkUserCodeClassLoader.loadClass(FlinkUserCodeClassLoader.java:52)
 ~[flink-dist-1.15.1.jar:1.15.1]
at java.lang.ClassLoader.loadClass(ClassLoader.java:351) ~[?:1.8.0_311]
at 
org.apache.flink.runtime.execution.librarycache.FlinkUserCodeClassLoaders$SafetyNetWrapperClassLoader.loadClass(FlinkUserCodeClassLoaders.java:172)
 ~[flink-dist-1.15.1.jar:1.15.1]
at java.lang.Class.forName0(Native Method) ~[?:1.8.0_311]
at java.lang.Class.forName(Class.java:348) ~[?:1.8.0_311]
at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:370) 
~[?:1.8.0_311]
at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404) 
~[?:1.8.0_311]
at java.util.ServiceLoader$1.next(ServiceLoader.java:480) ~[?:1.8.0_311]
at java.util.Iterator.forEachRemaining(Iterator.java:116) ~[?:1.8.0_311]
at 
org.apache.flink.connector.file.table.FileSystemTableFactory.formatFactoryExists(FileSystemTableFactory.java:205)
 ~[flink-connector-files-1.15.1.jar:1.15.1]
at 
org.apache.flink.connector.file.table.FileSystemTableFactory.discoverDecodingFormat(FileSystemTableFactory.java:171)
 ~[flink-connector-files-1.15.1.jar:1.15.1]
at 
org.apache.flink.connector.file.table.FileSystemTableFactory.createDynamicTableSource(FileSystemTableFactory.java:77)
 ~[flink-connector-files-1.15.1.jar:1.15.1]
at 
org.apache.flink.table.factories.FactoryUtil.createDynamicTableSource(FactoryUtil.java:156)
 ~[flink-table-api-java-uber-1.15.1.jar:1.15.1]
at 
org.apache.flink.table.factories.FactoryUtil.createDynamicTableSource(FactoryUtil.java:184)
 ~[flink-table-api-java-uber-1.15.1.jar:1.15.1]
at 
org.apache.flink.table.planner.plan.schema.CatalogSourceTable.createDynamicTableSource(CatalogSourceTable.java:175)
 ~[?:?]
at 
org.apache.flink.table.planner.plan.schema.CatalogSourceTable.toRel(CatalogSourceTable.java:115)
 ~[?:?]
at 
org.apache.calcite.sql2rel.SqlToRelConverter.toRel(SqlToRelConverter.java:3585) 
~[?:?]
at 
org.apache.calcite.sql2rel.SqlToRelConverter.convertIdentifier(SqlToRelConverter.java:2507)
 ~[?:?]
at 
org.apache.calcite.sql2rel.SqlToRelConverter.convertFrom(SqlToRelConverter.java:2144)
 ~[?:?]
at 
org.apache.calcite.sql2rel.SqlToRelConverter.convertFrom(SqlToRelConverter.java:2093)
 ~[?:?]
at 
org.apache.calcite.sql2rel.SqlToRelConverter.convertFrom(SqlToRelConverter.java:2050)
 ~[?:?]
at 
org.apache.calcite.sql2rel.SqlToRelConverter.convertSelectImpl(SqlToRelConverter.java:663)
 ~[?:?]
at 
org.apache.calcite.sql2rel.SqlToRelConverter.convertSelect(SqlToRelConverter.java:644)
 ~[?:?]
at 
org.apache.calcite.sql2rel.SqlToRelConverter.convertQueryRecursive(SqlToRelConverter.java:3438)
 ~[?:?]
at 
org.apache.calcite.sql2rel.SqlToRelConverter.convertQuery(SqlToRelConverter.java:570)
 ~[?:?]
at 
org.apache.flink.table.planner.calcite.FlinkPlannerImpl.org$apache$flink$table$planner$calcite$FlinkPlannerImpl$$rel(FlinkPlannerImpl.scala:197)
 ~[?:?]
at 
org.apache.flink.table.planner.calcite.FlinkPlannerImpl.rel(FlinkPlannerImpl.scala:189)
 ~[?:?]
at 
org.apache.flink.table.planner.operations.SqlToOperationConverter.toQueryOperation(SqlToOperationConverter.java:1240)
 ~[?:?]
at 
org.apache.flink.table.planner.operations.SqlToOperationConverter.convertSqlQuery(SqlToOperationConverter.java:1188)
 ~[?:?]
at 
org.apache.flink.table.planner.operations.SqlToOperationConverter.convertValidatedSqlNode(SqlToOperationConverter.java:345)
 ~[?:?]
at 
org.apache.flink.table.planner.operations.SqlToOperationConverter.convert(SqlToOperationConverter.java:238)
 ~[?:?]
at 
org.apache.flink.table.planner.delegation.ParserImpl.parse(ParserImpl.java:105) 
~[?:?]
at 
org.apache.flink.table.client.gateway.local.LocalExecutor.lambda$parseStatement$1(LocalExecutor.java:172)
 ~[flink-sql-client-1.15.1.jar:1.15.1]
at 
org.apache.flink.table.client.gateway.context.ExecutionContext.wrapClassLoader(ExecutionContext.java:88)
 ~[flink-sql-client-1.15.1.jar:1.15.1]
at 
org.apache.flink.table.client.gateway.local.LocalExecutor.parseStatement(LocalExecutor.java:172)
 ~[flink-sql-client-1.15.1.jar:1.15.1]
... 11 more
Caused by: java.lang.ClassNotFoundException: 
org.apache.flink.table.planner.delegation.ParserFactory
at java.net.URLClassLoader.findClass(URLClassLoader.java:387) ~[?:1.8.0_311]
at java.lang.ClassLoader.loadClass(ClassLoader.java:418) ~[?:1.8.0_311]
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355) ~[?:1.8.0_311]
at java.lang.ClassLoader.loadClass(ClassLoader.java:351) ~[?:1.8.0_311]
at java.lang.ClassLoader.defineClass1(Native Method) ~[?:1.8.0_311]
at java.lang.ClassLoader.defineClass(ClassLoader.java:756) ~[?:1.8.0_311]
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) 
~[?:1.8.0_311]
at java.net.URLClassLoader.defineClass(URLClassLoader.java:473) ~[?:1.8.0_311]
at java.net.URLClassLoader.access$100(URLClassLoader.java:74) ~[?:1.8.0_311]
at java.net.URLClassLoader$1.run(URLClassLoader.java:369) ~[?:1.8.0_311]
at java.net.URLClassLoader$1.run(URLClassLoader.java:363) ~[?:1.8.0_311]
at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_311]
at java.net.URLClassLoader.findClass(URLClassLoader.java:362) ~[?:1.8.0_311]
at java.lang.ClassLoader.loadClass(ClassLoader.java:418) ~[?:1.8.0_311]
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355) ~[?:1.8.0_311]
at java.lang.ClassLoader.loadClass(ClassLoader.java:405) ~[?:1.8.0_311]
at 
org.apache.flink.util.FlinkUserCodeClassLoader.loadClassWithoutExceptionHandling(FlinkUserCodeClassLoader.java:68)
 ~[flink-dist-1.15.1.jar:1.15.1]
at 
org.apache.flink.util.ChildFirstClassLoader.loadClassWithoutExceptionHandling(ChildFirstClassLoader.java:65)
 ~[flink-dist-1.15.1.jar:1.15.1]
at 
org.apache.flink.util.FlinkUserCodeClassLoader.loadClass(FlinkUserCodeClassLoader.java:52)
 ~[flink-dist-1.15.1.jar:1.15.1]
at java.lang.ClassLoader.loadClass(ClassLoader.java:351) ~[?:1.8.0_311]
at 
org.apache.flink.runtime.execution.librarycache.FlinkUserCodeClassLoaders$SafetyNetWrapperClassLoader.loadClass(FlinkUserCodeClassLoaders.java:172)
 ~[flink-dist-1.15.1.jar:1.15.1]
at java.lang.Class.forName0(Native Method) ~[?:1.8.0_311]
at java.lang.Class.forName(Class.java:348) ~[?:1.8.0_311]
at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:370) 
~[?:1.8.0_311]
at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404) 
~[?:1.8.0_311]
at java.util.ServiceLoader$1.next(ServiceLoader.java:480) ~[?:1.8.0_311]
at java.util.Iterator.forEachRemaining(Iterator.java:116) ~[?:1.8.0_311]
at 
org.apache.flink.connector.file.table.FileSystemTableFactory.formatFactoryExists(FileSystemTableFactory.java:205)
 ~[flink-connector-files-1.15.1.jar:1.15.1]
at 
org.apache.flink.connector.file.table.FileSystemTableFactory.discoverDecodingFormat(FileSystemTableFactory.java:171)
 ~[flink-connector-files-1.15.1.jar:1.15.1]
at 
org.apache.flink.connector.file.table.FileSystemTableFactory.createDynamicTableSource(FileSystemTableFactory.java:77)
 ~[flink-connector-files-1.15.1.jar:1.15.1]
at 
org.apache.flink.table.factories.FactoryUtil.createDynamicTableSource(FactoryUtil.java:156)
 ~[flink-table-api-java-uber-1.15.1.jar:1.15.1]
at 
org.apache.flink.table.factories.FactoryUtil.createDynamicTableSource(FactoryUtil.java:184)
 ~[flink-table-api-java-uber-1.15.1.jar:1.15.1]
at 
org.apache.flink.table.planner.plan.schema.CatalogSourceTable.createDynamicTableSource(CatalogSourceTable.java:175)
 ~[?:?]
at 
org.apache.flink.table.planner.plan.schema.CatalogSourceTable.toRel(CatalogSourceTable.java:115)
 ~[?:?]
at 
org.apache.calcite.sql2rel.SqlToRelConverter.toRel(SqlToRelConverter.java:3585) 
~[?:?]
at 
org.apache.calcite.sql2rel.SqlToRelConverter.convertIdentifier(SqlToRelConverter.java:2507)
 ~[?:?]
at 
org.apache.calcite.sql2rel.SqlToRelConverter.convertFrom(SqlToRelConverter.java:2144)
 ~[?:?]
at 
org.apache.calcite.sql2rel.SqlToRelConverter.convertFrom(SqlToRelConverter.java:2093)
 ~[?:?]
at 
org.apache.calcite.sql2rel.SqlToRelConverter.convertFrom(SqlToRelConverter.java:2050)
 ~[?:?]
at 
org.apache.calcite.sql2rel.SqlToRelConverter.convertSelectImpl(SqlToRelConverter.java:663)
 ~[?:?]
at 
org.apache.calcite.sql2rel.SqlToRelConverter.convertSelect(SqlToRelConverter.java:644)
 ~[?:?]
at 
org.apache.calcite.sql2rel.SqlToRelConverter.convertQueryRecursive(SqlToRelConverter.java:3438)
 ~[?:?]
at 
org.apache.calcite.sql2rel.SqlToRelConverter.convertQuery(SqlToRelConverter.java:570)
 ~[?:?]
at 
org.apache.flink.table.planner.calcite.FlinkPlannerImpl.org$apache$flink$table$planner$calcite$FlinkPlannerImpl$$rel(FlinkPlannerImpl.scala:197)
 ~[?:?]
at 
org.apache.flink.table.planner.calcite.FlinkPlannerImpl.rel(FlinkPlannerImpl.scala:189)
 ~[?:?]
at 
org.apache.flink.table.planner.operations.SqlToOperationConverter.toQueryOperation(SqlToOperationConverter.java:1240)
 ~[?:?]
at 
org.apache.flink.table.planner.operations.SqlToOperationConverter.convertSqlQuery(SqlToOperationConverter.java:1188)
 ~[?:?]
at 
org.apache.flink.table.planner.operations.SqlToOperationConverter.convertValidatedSqlNode(SqlToOperationConverter.java:345)
 ~[?:?]
at 
org.apache.flink.table.planner.operations.SqlToOperationConverter.convert(SqlToOperationConverter.java:238)
 ~[?:?]
at 
org.apache.flink.table.planner.delegation.ParserImpl.parse(ParserImpl.java:105) 
~[?:?]
at 
org.apache.flink.table.client.gateway.local.LocalExecutor.lambda$parseStatement$1(LocalExecutor.java:172)
 ~[flink-sql-client-1.15.1.jar:1.15.1]
at 
org.apache.flink.table.client.gateway.context.ExecutionContext.wrapClassLoader(ExecutionContext.java:88)
 ~[flink-sql-client-1.15.1.jar:1.15.1]
at 
org.apache.flink.table.client.gateway.local.LocalExecutor.parseStatement(LocalExecutor.java:172)
 ~[flink-sql-client-1.15.1.jar:1.15.1]
... 11 more


Thanks

在 2022-07-11 19:45:04,"Weihua Hu" <huweihua....@gmail.com> 写道:
>Hi,
>
>有更详细的日志吗?看起来是类加载冲突的,需要明确下是哪个类冲突了
>
>Best,
>Weihua
>
>
>On Wed, Jul 6, 2022 at 1:53 PM RS <tinyshr...@163.com> wrote:
>
>> Hi,
>>
>>
>> 通过sql-client执行flink sql,connector选择filesystem,会出现如下报错
>> java.lang.ClassNotFoundException:
>> org.apache.flink.table.planner.delegation.ParserFactory
>>
>>
>> Flink SQL> CREATE TABLE t1 (
>> > a STRING,
>> > b INT
>> > )WITH(
>> > 'connector'='filesystem',
>> > 'path'='/tmp/qwe',
>> > 'format'='csv',
>> > 'csv.ignore-parse-errors' = 'true',
>> > 'csv.allow-comments' = 'true'
>> > );
>> [INFO] Execute statement succeed.
>> Flink SQL> select * from t1;
>> [ERROR] Could not execute SQL statement. Reason:
>> java.lang.ClassNotFoundException:
>> org.apache.flink.table.planner.delegation.ParserFactory
>>
>>
>> 我测试了下,是因为我的lib目录下,有
>> flink-sql-connector-hive-3.1.2_2.12-1.15.0.jar,放lib下是因为还要其他任务需要读写hive
>> 如果lib下没有flink-sql-connector-hive-3.1.2_2.12-1.15.0.jar,则没有这个报错
>>
>>
>> 请教下,这个问题如何解决呢?
>>
>>
>> Thanks

回复