Hi, I current have a docker swarm running both fl...
# troubleshooting
k
Hi, I current have a docker swarm running both flink and kafka clusters. The clusters themselves seem fine and I am able to run the word_count.py example on the flink cluster. But when I am trying to run my own sample python job, I am greeted with this error:
Copy code
py4j.protocol.Py4JJavaError: An error occurred while calling o26.execute.
: java.net.MalformedURLException: no protocol: ['file:/opt/flink/opt/flink-python-1.20.0.jar']
perhaps someone have encountered this before and give me some pointers? For reference, here is my test pyflink job:
Copy code
from pyflink.datastream import StreamExecutionEnvironment, RuntimeExecutionMode, DataStream
from pyflink.common import WatermarkStrategy
from pyflink.datastream.connectors.kafka import KafkaSource, KafkaOffsetsInitializer
from pyflink.common.serialization import SimpleStringSchema
from pathlib import Path

def main():
    print(Path(__file__).parent)
    kafka_connector_jar_path = Path(__file__).parent / 'flink-sql-connector-kafka-3.3.0-1.20.jar'
    print(str(kafka_connector_jar_path.absolute()))

    env = StreamExecutionEnvironment.get_execution_environment()
    env.add_jars("file://" + str(kafka_connector_jar_path.absolute()))
    env.set_runtime_mode(RuntimeExecutionMode.STREAMING)
    env.set_parallelism(1)

    brokers = [
        'localhost:29092',  # broker-1
        'localhost:39092',  # broker-2
        'localhost:49092'   
    ]            

    source_builder = KafkaSource.builder()
    source_builder.set_bootstrap_servers(",".join(brokers))
    source_builder.set_topic_pattern("mock_data*")
    source_builder.set_group_id("test-group")
    source_builder.set_starting_offsets(KafkaOffsetsInitializer.earliest())
    source_builder.set_value_only_deserializer(SimpleStringSchema())
    kafka_source = source_builder.build()
    # source_builder._j_builder.setRackIdSupplier(RackSupplierImpl(lambda: "abc"))

    data_stream: DataStream = env.from_source(
        source=kafka_source,
        source_name="KafkaSource",
        watermark_strategy=WatermarkStrategy.no_watermarks()
    )

    data_stream.print()

    env.execute('Print data')

if __name__ == "__main__":
    main()
Seems like I am able to figure it out. Apparently I am using the jar file for my connector with the wrong java version. Rebuilding the docker images specifying the explicit java version resolves it.
d
@Kenneth Interesting. Which java version was used before?
k
I did not specify the version with the first image specifying version 17 seems to resolve it so I figure the jar is not compatible with what I have
d
OK. The connector jar is built against java 11 (https://github.com/apache/flink-connector-kafka/tree/v3.3) and so java version before that should not work.
a
I previously created a ticket for issue matching specified error: https://issues.apache.org/jira/browse/FLINK-36457 Not sure how rebuilding java version can solve this, since the issue is with handling list properties in yaml config by `add_jars`/`add_classpaths` methods