2

I am trying to understand the Apache Flink CEP program to monitor rack temperatures in a data center as described by Flink Official Documentation. But when I follow the steps and create a jar using mvn clean package and tried to execute the package using the command

java -cp "../cep-monitoring-1.0.jar" org.stsffap.cep.monitoring.CEPMonitoring

But I get the following error,

Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/flink/streaming/api/functions/source/SourceFunction
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
    at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
    at java.lang.Class.getMethod0(Class.java:3018)
    at java.lang.Class.getMethod(Class.java:1784)
    at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
    at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException: org.apache.flink.streaming.api.functions.source.SourceFunction
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 7 more

I tried different variations of giving the classpath as described here but getting the same error. Can someone point out my mistake in running the program?

3
  • Are you trying to submit a job to the local flink cluster? Commented Feb 22, 2018 at 11:40
  • Yes. So the flink cluster should be executed explicitly in the background? Commented Feb 22, 2018 at 13:57
  • You could include a piece of your pom.xml to better understand if you have the dependencies. Commented Feb 22, 2018 at 14:25

2 Answers 2

2

To submit a job to the local Flink cluster:

  1. Run Flink.

/path/to/flink-1.4.0/bin/start-local.sh

  1. Submit the job.

/path/to/flink-1.4.0/bin/flink run -c com.package.YourClass /path/to/jar.jar

Alternatively you can run the job simply from your IDE:

Your job in this case will be run in a Flink environement. Check Flink's example: https://github.com/apache/flink/blob/master/flink-examples/flink-examples-streaming/src/main/java/org/apache/flink/streaming/examples/wordcount/WordCount.java

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

Comments

1

The cep example uses flink version 1.3.2. So here are the steps to run it.

  1. Install version 1.3.2 of apache flink. (wget it from here and extract it).
  2. cd into flink-1.3.2
  3. ./bin/start-local.sh, this will start the flink cluster. Do cd ...
  4. Clone this repo using git clone and cd into that.
  5. mvn clean package to build the project. This will create target directory.
  6. Run ../flink-1.3.2/bin/flink run target/cep-monitoring-1.0.jar, to start the process.
  7. In separate terminal the output can be logged like this (assuming that you are in same directory as previous step) tail -f ../flink-1.3.2/log/flink-*-jobmanager-*.out (* will be replaced by specific user detail, press tab to autocomplete those).

Here is the sample output,

rshah9@bn18-20:~/tools/cep-monitoring-master$ tail -f ../flink-1.3.2/log/flink-rshah9-jobmanager-0-bn18-20.dcs.mcnc.org.out
TemperatureWarning(9, 102.45860162626161)
TemperatureWarning(6, 113.21295716135027)
TemperatureWarning(5, 105.46064102697723)
TemperatureWarning(0, 106.44635415722034)
TemperatureWarning(4, 112.07396748089734)
TemperatureWarning(9, 114.53346561628322)
TemperatureWarning(3, 109.05305417712648)
TemperatureWarning(7, 112.3698094257147)
TemperatureWarning(3, 107.78609416982076)
TemperatureWarning(9, 107.34373990230458)
TemperatureWarning(5, 111.46480675461656)

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.