背景
最近,我司決定將flink 從1.7.2升級到1.8.1。但是,flink 1.8.1運行jar,基於on yarn的模式就會報錯。
問題以及解決
運行日誌,一開始
Setting HADOOP_CONF_DIR=/etc/hadoop/conf because no HADOOP_CONF_DIR was set.
然後就出現Could not build the program from JAR file。但是用1.7.2的版本就可以跑通,於是發現1.8.1版本中,flink不會自帶hadoop的jar了,需要自己去官網下載 https://flink.apache.org/downloads.html
可以選擇對應版本,我是2.5版本的hadoop,選擇了2.6.5。然後將下載下來的jar放入,flink的jar目錄下(我這邊是/var/flink-1.8.1/lib)
再運行,就會出現各種ClassNotFoundException。
包括:
ClassNotFoundException: com.sun.jersey.core.util.FeaturesAndProperties
ClassNotFoundException: org.glassfish.jersey.internal.RuntimeDelegateImpl
ClassNotFoundException: javax.ws.rs.ext.MessageBodyReader
這裏整理了一下,所需要的jar
<!-- <!– https://mvnrepository.com/artifact/org.glassfish.jersey.core/jersey-common –>-->
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-common</artifactId>
<version>2.27</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.sun.jersey/jersey-core -->
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-core</artifactId>
<version>1.19.4</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.sun.jersey/jersey-client -->
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<version>1.19.4</version>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.ws.rs/javax.ws.rs-api -->
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.0.1</version>
</dependency>
將上述的依賴放入IDE中,讓maven去下載,然後在去對應的maven倉庫去拿下載好的jar,再上傳上去,即可。
最後將上傳的jar,都變爲777權限(這步,不知道需不需要,反正我是都改了)
問題得到解決,可以正常運行了。