Ljupco Vangelski
01/19/2024, 7:32 PMsql-gateway.sh but I cannot seam to make it work.
I am running everything in Kubernetes, on the latest apache/flink:latest image.
I downloaded the flink-sql-connector-kafka-3.0.2-1.18.jar jar file and I am testing the statement first through the sql-client.sh :
sql-client.sh -j flink-sql-connector-kafka-3.0.2-1.18.jar
The statement is (I'm using Confluent Kafka):
CREATE TABLE input_1 (product STRING, amount INT)
WITH (
'connector' = 'kafka',
'topic' = 'purchases',
'format' = 'json',
'properties.group.id' = 'test',
'scan.startup.mode' = 'earliest-offset',
'properties.bootstrap.servers' = 'broker:9092',
'properties.security.protocol' = 'SASL_SSL',
'properties.sasl.mechanism' = 'PLAIN',
'properties.sasl.jaas.config' = 'org.apache.flink.kafka.shaded.org.apache.kafka.common.security.plain.PlainLoginModule required username="user" password="pass";'
);
when I then try
select * from input_1;
everything works correctly.
But now I am trying to send the statement through the sql-gateway.sh. As I cannot (don't know how to) pass the JAR to the command, I added the flink-sql-connector-kafka-3.0.2-1.18.jar file to the /opt/flink/lib directory and am starting the sql-gateway like this:
sql-gateway.sh start -Dsql-gateway.endpoint.rest.address=0.0.0.0
I can see that the jar is loaded with ps -Af
flink 1982 1 18 19:18 pts/0 00:00:02 /opt/java/openjdk/bin/java -XX:+IgnoreUnrecognizedVMOptions -Dlog.file=/opt/flink/log/flink--sql-gateway-0-flink-jobmanager-68d8645577-hndpz.log -Dlog4j.configuration=file:/opt/flink/conf/log4j.properties -Dlog4j.configurationFile=file:/opt/flink/conf/log4j.properties -Dlogback.configurationFile=file:/opt/flink/conf/logback.xml -classpath /opt/flink/lib/flink-cep-1.18.1.jar:/opt/flink/lib/flink-connector-files-1.18.1.jar:/opt/flink/lib/flink-csv-1.18.1.jar:/opt/flink/lib/flink-json-1.18.1.jar:/opt/flink/lib/flink-scala_2.12-1.18.1.jar:/opt/flink/lib/flink-sql-connector-kafka-3.0.2-1.18.jar:/opt/flink/lib/flink-table-api-java-uber-1.18.1.jar:/opt/flink/lib/flink-table-planner-loader-1.18.1.jar:/opt/flink/lib/flink-table-runtime-1.18.1.jar:/opt/flink/lib/log4j-1.2-api-2.17.1.jar:/opt/flink/lib/log4j-api-2.17.1.jar:/opt/flink/lib/log4j-core-2.17.1.jar:/opt/flink/lib/log4j-slf4j-impl-2.17.1.jar:/opt/flink/lib/flink-dist-1.18.1.jar:/opt/flink/opt/flink-sql-gateway-1.18.1.jar:/opt/flink/opt/flink-python-1.18.1.jar::: org.apache.flink.table.gateway.SqlGateway -Dsql-gateway.endpoint.rest.address=0.0.0.0
The REST point works correctly on port 8083, I can create the session and I can post the query
curl -X POST flink-jobmanager:8083/v1/sessions/
curl -X POST flink-jobmanager:8083/v1/sessions/id/statements/ --data @statement1 (succeeds and returns an operational handle)
curl -X POST flink-jobmanager:8083/v1/sessions/id/statements/ --data '{"statement": "select * from input_1;"}' (succeeds and returns an operational handle)
And when I try to get the result,
curl -X GET flink-jobmanager:8083/v1/sessions/id/operations/id/result/0 | jq .
I am getting the error `Unknown Source`:
org.apache.flink.streaming.runtime.tasks.StreamTaskException: Cannot load user class: org.apache.flink.connector.kafka.source.KafkaSource
java.lang.Thread.run(Unknown Source)\nCaused by: java.lang.ClassNotFoundException: org.apache.flink.connector.kafka.source.KafkaSource\n\tat java.base/java.net.URLClassLoader.findClass(Unknown Source)\n\tat java.base/java.lang.ClassLoader.loadClass(Unknown Source)\n\tat org.apache.flink.util.FlinkUserCodeClassLoader.loadClassWithoutExceptionHandling(FlinkUserCodeClassLoader.java:67)\n\tat
So I guess I am not loading properly the flink-sql-connector-kafka-3.0.2-1.18.jar file so that I can use it through the Flink sql-gateway . My question is: what am I doing wrong and what is the recommended way to load the Kafka connector jar (in Flink or in the Flink gateway), so that I can execute statements to Kafka as a source, through the REST API of the Flink Gateway.
Sorry for the lengthy post 🙌 , I tried a few things, searched through the documentation and am stuck at the moment. Please help 🙏Ljupco Vangelski
01/19/2024, 7:32 PMsql-client.sh works properly.hùng trần việt
01/22/2024, 3:15 AMapache/flink:latest image doesn’t have flink-sql-connector-kafka-3.0.2-1.18.jar by default, you should build your own flink image, add that jar file and run againLjupco Vangelski
01/22/2024, 6:15 AMflink-sql-connector-kafka-3.0.2-1.18.jar to the /opt/flink/lib directory should work? Or should I do something else?hùng trần việt
01/22/2024, 7:20 AM/opt/flink/lib/ directory.Ljupco Vangelski
01/22/2024, 9:58 PMflink-sql-connector-kafka-3.0.2-1.18.jar is not compatible with the current apache/flink:latest.
What worked for me is the previous Flink version:
• Docker image: flink:1.17.2-scala_2.12-java8
• Connector: flink-sql-connector-kafka-1.17.2.jarMartijn Visser
01/23/2024, 7:06 AMMartijn Visser
01/23/2024, 7:06 AMMartijn Visser
01/23/2024, 7:07 AMLjupco Vangelski
01/23/2024, 8:29 AM