Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache Flink - org.apache.flink.client.program.ProgramInvocationException

I have created an application with Apache FLink 1.0.3 using Scala 2.11.7 and I want to test it locally (a single jvm). So I did the following as stated in the website:

./bin/start-local.sh
tail log/flink-*-jobmanager-*.log

And it starts just fine, I can see the web interface at localhost:8081. Then, I tried to submit my application, but I get either an exception or a weird message. For example when I type either of the following commands:

./bin/flink run ./myApp.jar
./bin/flink run ./myApp.jar -c MyMain
./bin/flink run ./myApp.jar -c myMain.class
./bin/flink run ./myApp.jar -c myMain.scala
./bin/flink run ./myApp.jar -c my.package.myMain
./bin/flink run ./myApp.jar -c my.package.myMain.class
./bin/flink run ./myApp.jar -c my.package.myMain.scala

I get the following exception:

------------------------------------------------------------
 The program finished with the following exception:

org.apache.flink.client.program.ProgramInvocationException: Neither a 'Main-Class', nor a 'program-class' entry was found in the jar file.
    at org.apache.flink.client.program.PackagedProgram.getEntryPointClassNameFromJar(PackagedProgram.java:571)
    at org.apache.flink.client.program.PackagedProgram.<init>(PackagedProgram.java:188)
    at org.apache.flink.client.program.PackagedProgram.<init>(PackagedProgram.java:126)
    at org.apache.flink.client.CliFrontend.buildProgram(CliFrontend.java:922)
    at org.apache.flink.client.CliFrontend.run(CliFrontend.java:301)
    at org.apache.flink.client.CliFrontend.parseParameters(CliFrontend.java:1192)
    at org.apache.flink.client.CliFrontend.main(CliFrontend.java:1243)

And when I type either of the following commands:

./bin/flink run ./ -c myMain myApp.jar
./bin/flink run ./ -c myMain.class myApp.jar
./bin/flink run ./ -c myMain.scala myApp.jar
./bin/flink run ./ -c my.package.myMain myApp.jar
./bin/flink run ./ -c my.package.myMain.class myApp.jar
./bin/flink run ./ -c my.package.myMain.scala myApp.jar

I get the following error:

JAR file is not a file: .

Use the help option (-h or --help) to get help on the command.

The above commands do not work either with -c or --class. I use IntelliJ and I compiled the application using the Build Module from Dependencies option. What am I doing wrong?

like image 579
Al Jenssen Avatar asked Dec 04 '22 00:12

Al Jenssen


2 Answers

The correct way to submit your JAR is:

bin/flink run -c my.package.myMain myApp.jar

You have to specify the arguments (like -c) before the JAR file. You got the error messages initially, because ./ was interpreted as the JAR and the rest of the line was ignored.

The -p argument is optional. Your last example works, because the argument order is correct and not because of the parallelism flag.

like image 199
uce Avatar answered Dec 28 '22 15:12

uce


I figured out what was wrong. Flink needed to pass the parallelism degree as an argument, otherwise there was a program invocation exception. The command below worked for me:

./bin/flink run -p2 --class myMain myApp.jar
like image 35
Al Jenssen Avatar answered Dec 28 '22 16:12

Al Jenssen