2
votes

I am trying to run the example program using Flink. I downloaded the example project using

mvn archetype:generate -DarchetypeGroupId=org.apache.flink -DarchetypeArtifactId=flink-quickstart-scala -DarchetypeVersion=0.8.1

I then ran the following command on a terminal

mvn package && java -cp target/test-1.0-SNAPSHOT.jar adfin.WordCount

I got the following error

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/flink/api/common/typeinfo/TypeInformation at adfin.WordCount.main(WordCount.scala) Caused by: java.lang.ClassNotFoundException: org.apache.flink.api.common.typeinfo.TypeInformation at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

I tried updating the library from the default 0.8.1 to 1.0.0 but that didn't change anything. I suppose there might be an extra jar I would have to add in. Can anyone help?

1

1 Answers

7
votes

The example project's Maven configuration uses flink dependencies within the provided scope. The jar file compiled with mvn package command is built to be submitted to a flink cluster, not to be run in stand-alone mode, therefore it does not include flink jars (hence the NoClassDefFoundError exception). Include the flink libraries into your classpath and your command will run fine.