在ubuntu中使用无形的sbt-assembly着色错误

时间:2017-04-26 18:08:25

标签: scala apache-spark shapeless sbt-assembly pureconfig

如果有人可以提供帮助,sbt-assembly我会遇到一个奇怪的问题

当尝试使用应用于shapeless库的着色来创建胖jar以部署到Spark时,我发现在Ubuntu机器上运行时没有重命名某些类,而sbt assembly时所有内容都被重命名在Mac上运行。

这是阴影配置

assemblyShadeRules in assembly := Seq(
  ShadeRule.rename("shapeless.**" -> "shadedshapeless.@1")
    .inLibrary("com.chuusai" % "shapeless_2.11" % "2.3.2")
    .inLibrary("com.github.pureconfig" % "pureconfig_2.11" % "0.7.0")
    .inProject)

在Mac中运行时,这些类将重命名为模式shapeless/Generic*

Renamed shapeless/Generic$.class -> shadedshapeless/Generic$.class
Renamed shapeless/Generic.class -> shadedshapeless/Generic.class
Renamed shapeless/Generic1$.class -> shadedshapeless/Generic1$.class
Renamed shapeless/Generic1$class.class -> shadedshapeless/Generic1$class.class
Renamed shapeless/Generic1.class -> shadedshapeless/Generic1.class
Renamed shapeless/Generic10$class.class -> shadedshapeless/Generic10$class.class
Renamed shapeless/Generic10.class -> shadedshapeless/Generic10.class
Renamed shapeless/Generic1Macros$$anonfun$1.class -> shadedshapeless/Generic1Macros$$anonfun$1.class
Renamed shapeless/Generic1Macros$$anonfun$2.class -> shadedshapeless/Generic1Macros$$anonfun$2.class
Renamed shapeless/Generic1Macros.class -> shadedshapeless/Generic1Macros.class
Renamed shapeless/GenericMacros$$anonfun$23.class -> shadedshapeless/GenericMacros$$anonfun$23.class
Renamed shapeless/GenericMacros.class -> shadedshapeless/GenericMacros.class

但是在Ubuntu中运行时,对于模式shapless/Generic*,只有这些内容被重命名

Renamed shapeless/GenericMacros$$anonfun$23.class -> shadedshapeless/GenericMacros$$anonfun$23.class
Renamed shapeless/Generic1Macros$$anonfun$1.class -> shadedshapeless/Generic1Macros$$anonfun$1.class
Renamed shapeless/Generic1$.class -> shadedshapeless/Generic1$.class
Renamed shapeless/Generic1.class -> shadedshapeless/Generic1.class

我在向shapeless/Generic*提供胖罐(在Ubuntu中生成)时选择了模式spark-submit coz然后立即收到错误(可能来自pureconfig

Exception in thread "main" java.lang.NoClassDefFoundError: shadedshapeless/Generic

当Mac中生成的胖罐被送到spark-submit

时,不会发生错误

1 个答案:

答案 0 :(得分:0)

我不确定为什么Ubuntu着色与MacO的工作方式不同,但我看到的一个问题就是你只是对无形的部分进行着色。我不认为这是一个好主意,可以给你带来问题,因为你会混合不同版本的无形。我的建议是为PureConfig尝试完全无形阴影。只需添加

assemblyShadeRules in assembly := Seq(ShadeRule.rename("shapeless.**" -> "new_shapeless.@1").inAll)

到你的sbt文件。我在Ubuntu 16.04上使用PureConfig 7.2和Spark 2.1.0对此解决方案进行了测试。请参阅FAQ section of PureConfig about this issue