【问题标题】:Spark 2.X throwing io.netty.buffer.PooledByteBufAllocator.metric()Lio/netty/buffer/PooledByteBufAllocatorMetricSpark 2.X 抛出 io.netty.buffer.PooledByteBufAllocator.metric()Lio/netty/buffer/PooledByteBufAllocatorMetric
【发布时间】:2019-07-20 02:58:35
【问题描述】:

我在尝试运行 Spark 时一直看到此错误,我曾尝试将 Spark 用于 2.3.2、2.3.3 和 2.4.3

java.lang.NoSuchMethodError: io.netty.buffer.PooledByteBufAllocator.metric()Lio/netty/buffer/PooledByteBufAllocatorMetric; 在 org.apache.spark.network.util.NettyMemoryMetrics.registerMetrics(NettyMemoryMetrics.java:80) 在 org.apache.spark.network.util.NettyMemoryMetrics.(NettyMemoryMetrics.java:76) 在 org.apache.spark.network.client.TransportClientFactory.(TransportClientFactory.java:109) 在 org.apache.spark.network.TransportContext.createClientFactory(TransportContext.java:99)

在该块的最后一行调用:

lazy val spark: SparkSession = {
    SparkSession
      .builder()
      .appName("SparkProfiler")
      .master("local[*]").config("spark.driver.host", "localhost")
      .getOrCreate()
  }

我已经尝试过类似线程暗示的建议,但无济于事。

例如,在我的 build.sbt 中,我有这些依赖项覆盖

dependencyOverrides += "io.netty" % "netty" % "3.9.9.Final" // have tried not including this
dependencyOverrides += "io.netty" % "netty-all" % "4.1.8.Final"
dependencyOverrides += "io.netty" % "netty-buffer" % "3.9.9.Final" // have tried keeping this version to 4.1.8Final
dependencyOverrides += "io.netty" % "netty-codec" % "4.1.8.Final"
dependencyOverrides += "io.netty" % "netty-codec-http" % "4.1.8.Final"
dependencyOverrides += "io.netty" % "netty-common" % "4.1.8.Final"
dependencyOverrides += "io.netty" % "netty-handler" % "4.1.8.Final"
dependencyOverrides += "io.netty" % "netty-resolver" % "4.1.8.Final"
dependencyOverrides += "io.netty" % "netty-transport" % "4.1.8.Final"

当我查看外部库时,我确实看到了:

sbt: io.netty:netty:3.9.9.Final.jar
sbt: io.netty:netty-all:4.1.8.Final.jar

但我也尝试在我的 build.sbt 中包含:

excludeDependencies ++= ExclusionRule("io.netty", "netty")

这样sbt: io.netty:netty:3.9.9.Final.jar 就从我的外部库中排除了。

当我通过 IntelliJ 探索错误并进入导入的 NettyMemoryMetrics 类时,我确实在导入中看到 import io.netty.buffer.PooledByteBufAllocatorMetric; 找不到。我认为这可以通过将 netty-all 保留在依赖项中来解决,但似乎无法在构建后为 Spark 找到正确的组合来找到此类。有什么建议吗?

【问题讨论】:

    标签: scala apache-spark


    【解决方案1】:

    终于在这条评论里找到了答案:

    https://stackoverflow.com/a/51565332/7082628

    添加到 build.sbt:我所有的 netty 版本都需要为 4.1.17,而不是 4.1.8,除了普通的“netty”

    dependencyOverrides += "io.netty" % "netty" % "3.9.9.Final"
    dependencyOverrides += "io.netty" % "netty-all" % "4.1.17.Final"
    dependencyOverrides += "io.netty" % "netty-buffer" % "4.1.17.Final"
    dependencyOverrides += "io.netty" % "netty-codec" % "4.1.17.Final"
    dependencyOverrides += "io.netty" % "netty-codec-http" % "4.1.17.Final"
    dependencyOverrides += "io.netty" % "netty-common" % "4.1.17.Final"
    dependencyOverrides += "io.netty" % "netty-handler" % "4.1.17.Final"
    dependencyOverrides += "io.netty" % "netty-resolver" % "4.1.17.Final"
    dependencyOverrides += "io.netty" % "netty-transport" % "4.1.17.Final"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-04-08
      • 2023-03-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多