I am writing a Flink job to send a data stream to elasticsearch. I am using Maven and IntelliJ. When I try to test the job within IntelliJ I get the following error: java.lang.NoClassDefFoundError: org/apache/flink/api/connector/sink2/Sink
the job code is quite simple, see below.
public static void main(String[] args) throws Exception {
final ParameterTool params = ParameterTool.fromArgs(args);
input = params.get("input");
//1. creao un stream execution environment
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
//2. creo un data stream da una fonte
DataStream<String> inputdatastream = env.addSource(new ProvaDataSource());
//3. faccio x con il datas stream
//4. manda il risultato di 3 ad un data sink, es .print()
inputdatastream.sinkTo(
new Elasticsearch7SinkBuilder<String>()
.setBulkFlushMaxActions(1)
.setHosts(new HttpHost("localhost", 9200, "http"))
.setEmitter(
(element, context, indexer) ->
indexer.add(new IndexRequest("my-index")
.id(element)
.source(element)))
.build());
//5 esegui
env.execute(Example2.class.getName());
}
Any suggestion about what to change?
I have been checking the dependencies and got the latest available in the apache flink website (I am using flink version 1.17.1) see below:
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-connector-elasticsearch7</artifactId>
<version>3.0.1-1.17</version>
<scope>compile</scope>
</dependency>
I already cleared and rebuilt the project.