5

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?

5
  • Could it be that myApp.jar does not contain the MyMain class? Could you maybe run jar -tf myApp.jar and verify that it contains the above-mentioned class and that this class contains a main method? Commented May 26, 2016 at 7:31
  • I used the command you mentioned and for a weird reason I couldnt find any of the classes I created. Why is that happening? Commented May 26, 2016 at 7:55
  • I used WinRar to open the jar and see its contents and I could locate every class of my project and I could locate MyMain.class and MyMain$.class Commented May 26, 2016 at 8:17
  • Maybe that's the problem that the jar command cannot list the contents properly. This could indicate that you jar file is somehow corrupted. Commented May 26, 2016 at 8:59
  • Sorry, for my incorrect previous comment. I could finally locate my main class with the command you provided. I am quite sure that the jar file is not corrupted. Commented May 27, 2016 at 9:04

3 Answers 3

15

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.

Sign up to request clarification or add additional context in comments.

Comments

3

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

Comments

1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.