Apache spark Spark无法从fat jar资源加载自定义log4j.properties

Apache spark Spark无法从fat jar资源加载自定义log4j.properties,apache-spark,Apache Spark,我正在尝试新的和改进的spark 1.4.1,但我经历了一次回归 spark提交我的jar时,我传递指令以加载绑定在fat jar资源中的定制log4j-light-redis.properties。在spark 1.3.1中,这就像一个符咒。在1.4.1中,资源加载器找不到它: log4j: Trying to find [log4j-light-redis.properties] using context classloader sun.misc.Launcher$AppClassLoad

我正在尝试新的和改进的spark 1.4.1,但我经历了一次回归

spark提交我的jar时,我传递指令以加载绑定在fat jar资源中的定制log4j-light-redis.properties。在spark 1.3.1中,这就像一个符咒。在1.4.1中,资源加载器找不到它:

log4j: Trying to find [log4j-light-redis.properties] using context classloader sun.misc.Launcher$AppClassLoader@4e25154f.
log4j: Trying to find [log4j-light-redis.properties] using sun.misc.Launcher$AppClassLoader@4e25154f class loader.
log4j: Trying to find [log4j-light-redis.properties] using ClassLoader.getSystemResource().
log4j: Could not find resource: [log4j-light-redis.properties].
在spark 1.3.1中,它将正确找到资源:

log4j: Trying to find [log4j-light-redis.properties] using context classloader org.apache.spark.util.MutableURLClassLoader@1a1d6a08.
log4j: Using URL [jar:file:/E:/Projects/.../target/fatjar-1.1-SNAPSHOT-shaded.jar!/log4j-light-redis.properties] for automatic log4j configuration.
log4j: Reading configuration from URL jar:file:/E:/Projects/.../target/fatjar-1.1-SNAPSHOT-shaded.jar!/log4j-light-redis.properties
log4j: Parsing for [root] with value=[WARN,console,redis].
有人也有同样的问题,但spark邮件列表仍然没有承认这个问题:

更新
看起来这件事比我想象的更糟。。我再也无法从我的胖罐子中加载自定义log4j appender了!它失败,出现ClassNotFoundException

在1.4.1中,不像在1.3.1中那样,在log4j初始化之前设置MutableURLClassLoader

解释如下:


在解析SparkSubmit.scala中的参数时,它使用spark.util.Utils。此对象通过ShutdownHookManager在log4j上有一个新的静态依赖项,它在spark用户邮件列表上发布的submit>doRunMain>runMain调用setContextClassLoader(MutableURLClassLoader)之前触发其初始化。。