Poison

Uber JAR

在 Spark、Flink 应用等场景下,经常会将业务代码构造为一个 Uber jar 提交至集群运行,在一次 Hive-UDF 的集成过程中,使用 Apache Maven Shade Plugin 进行 Uber jar 构建后,加载类时提示找不到类,我将该 Uber jar 拉取至本地解压后发现类是存在的,但错误日志仅提示找不到类,后经过反复排查,原来是 Jar 包签名问题导致,只是我遇到的场景并未提示签名问题导致难以排查。

1
2
3
4
5
6
7
8
9
10
11
12
<filters>
<filter>
<!-- Do not copy the signatures in the META-INF folder.
Otherwise, this might cause SecurityExceptions when using the JAR. -->
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
Reference

JAR File Specification, Signed JAR File
“Invalid signature file” when attempting to run a .jar
Appendix: Template for building a Jar with Dependencies | Apache Flink