2017-10-28 127 views
0

引起弗林克儀表盤版本1.3.2 CEP模式我已經寫了這樣無法執行是由ClassNotFoundException的

Pattern<JoinedEvent, ?> pattern = Pattern.<JoinedEvent>begin("start") 
      .where(new SimpleCondition<JoinedEvent>() { 
    @Override 
    public boolean filter(JoinedEvent streamEvent) throws Exception { 

      return streamEvent.getRRInterval()>= 10 ; 
         } 
      }).within(Time.milliseconds(WindowLength)); 

一個簡單的模式,它在IntellijIdea執行好。我在儀表板和IntelliJ-Idea中都使用Flink 1.3.2。當我從源代碼構建Flink時,我看到了很多警告消息,這些消息讓我相信迭代條件類沒有被包含在jar中,因爲錯誤也表示爲ClassNotFoundException。以下是錯誤

Caused by: java.lang.NoClassDefFoundError: org/apache/flink/cep/pattern/conditions/IterativeCondition 
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 

org.apache.flink.client.program.PackagedProgram.hasMainMethod(PackagedProgram.java:492) 
    ... 38 more 
Caused by: java.lang.ClassNotFoundException: org.apache.flink.cep.pattern.conditions.IterativeCondition 
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357) 
    ... 44 more 

回答

0

經過整整一天的努力解決這個問題,最後,我得到了解決方案。問題很簡單,就是Flink CEP不是二進制發行版的一部分,所以每當我嘗試執行模式時,都會給我一個錯誤。

解決方法很簡單

enter image description here

正如你可以看到弗林克二進制不具有CEP罐子。

所以去你的IDE是的IntelliJ在我的情況,並複製所需的jar

回到這個位置,複製粘貼到您的二進制版本,這個罐子lib文件夾。

Yalaa,問題就解決了

0

如果你不想手動添加依賴關係,或者你有一個Maven或SBT項目,你可以簡單地添加依賴於.pom文件或相應的SBT文件,並添加下面的依賴關係。

根據您的項目需要更改flink版本。

<!-- https://mvnrepository.com/artifact/org.apache.flink/flink-cep_2.11 --> 
<dependency> 
    <groupId>org.apache.flink</groupId> 
    <artifactId>flink-cep_2.11</artifactId> 
    <version>1.3.2</version> 
</dependency> 


// https://mvnrepository.com/artifact/org.apache.flink/flink-cep_2.11 
libraryDependencies += "org.apache.flink" % "flink-cep_2.11" % "1.3.2"