1

Can anybody help me with the following error? I think there are some problems with versions, but I have no idea on how to fix it. I'm trying to run Apache Flink, I use Kafka topic as an input to this I'm getting the following error when trying to run Flink:

Error:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/flink/util/Preconditions at org.apache.flink.cep.pattern.Pattern.where(Pattern.java:130) at hes.cs63.CEPMonitor.CEPMonitoring.main(CEPMonitoring.java:55) Caused by: java.lang.ClassNotFoundException: org.apache.flink.util.Preconditions 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) ... 2 more

pom.xml:

<dependencies>
    <dependency>
        <groupId>org.apache.flink</groupId>
        <artifactId>flink-streaming-java_2.10</artifactId>
        <version>1.0.2</version>
    </dependency>
    <dependency>
        <groupId>org.apache.flink</groupId>
        <artifactId>flink-cep_2.11</artifactId>
        <version>1.3.2</version>
    </dependency>
    <dependency>
        <groupId>org.apache.kafka</groupId>
        <artifactId>kafka-clients</artifactId>
        <version>0.9.0.1</version>
    </dependency>
    <dependency>
        <groupId>org.apache.flink</groupId>
        <artifactId>flink-connector-kafka-0.9_2.10</artifactId>
        <version>1.0.2</version>
    </dependency>
    <dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
        <version>2.6.2</version>
    </dependency>
</dependencies>
3
  • How are you executing the code? Commented Nov 21, 2017 at 0:38
  • From InteliJ IDEA with there parameters: '--topic CEP --bootstrap.servers localhost:9092 --group.id SBG --out file:///home/user/' Commented Nov 21, 2017 at 0:41
  • As you mentioned earlier, it might be related to conflicting dependencies. Can you run the following command mvn dependency:tree -Dverbose to verify if there are any conflicts. Commented Nov 21, 2017 at 1:03

2 Answers 2

1

You should update the flink-streaming-java_2.10 and flink-connector-kafka-0.9_2.10 dependencies to version 1.3.2, to the match the version of the CEP library. And be consistent about scala versions -- pick either 2.10 or 2.11 for all dependencies.

CEP is much improved since 1.0.2, so I wouldn't recommend downgrading CEP.

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

Comments

0

Your dependency flink-cep_2.11 uses scala 2.11 and flink 1.3.2, while flink-streaming-java_2.10 and flink-connector-kafka-0.9_2.10 use scala 2.10 and flink 1.0.2.

You can downgrade flink-cep to get scala 2.10 and flink 1.0.2 for all deps:

<dependency>
    <groupId>org.apache.flink</groupId>
    <artifactId>flink-cep_2.10</artifactId>
    <version>1.0.2</version>
</dependency>

This will give the minimal diff in your pom.xml, but you'll be using libraries from early 2016. Hence, a better solution is to upgrade the two other deps to version 1.3.2 and scala 2.11:

<dependencies>
  <dependency>
    <groupId>org.apache.flink</groupId>
    <artifactId>flink-streaming-java_2.11</artifactId>
    <version>1.3.2</version>
  </dependency>
  <dependency>
    <groupId>org.apache.flink</groupId>
    <artifactId>flink-cep_2.11</artifactId>
    <version>1.3.2</version>
  </dependency>
  <dependency>
    <groupId>org.apache.kafka</groupId>
    <artifactId>kafka-clients</artifactId>
    <version>0.9.0.1</version>
  </dependency>
  <dependency>
    <groupId>org.apache.flink</groupId>
    <artifactId>flink-connector-kafka-0.9_2.11</artifactId>
    <version>1.3.2</version>
  </dependency>
  <dependency>
    <groupId>com.google.code.gson</groupId>
    <artifactId>gson</artifactId>
    <version>2.6.2</version>
  </dependency>
</dependencies>

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.