Al Jenssen
Al Jenssen

Reputation: 695

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?

Upvotes: 5

Views: 12106

Answers (3)

Shripad S Barne
Shripad S Barne

Reputation: 31

You have to mention the entry point class in your pom file. see the following part in the pom file snippety

<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.xyz.myMain</mainClass>
</transformer>
</transformers>

Please check the below snippet.

Upvotes: 1

uce
uce

Reputation: 151

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.

Upvotes: 15

Al Jenssen
Al Jenssen

Reputation: 695

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

Upvotes: 3

Related Questions