弟弟别拦我 发表于 2018-7-24 14:30:15

Spark Streaming 中使用grpc ,在服务器上运行时报错

在spark程序中使用grpc,用maven构建项目,打好jar包后在集群中运行,报错: java.lang.NoClassDefFoundError: Could not initialize class io.grpc.netty.NettyChannelBuilder
at io.grpc.netty.NettyChannelProvider.builderForAddress(NettyChannelProvider.java:37)
at io.grpc.netty.NettyChannelProvider.builderForAddress(NettyChannelProvider.java:23)
at io.grpc.ManagedChannelBuilder.forAddress(ManagedChannelBuilder.java:36)
at adonline.DaybugetClient.<init>(DaybugetClient.java:47)
at adonline.RptAdvertiser$$anonfun$main$1$$anonfun$apply$2.apply(RptAdvertiser.scala:52)
at adonline.RptAdvertiser$$anonfun$main$1$$anonfun$apply$2.apply(RptAdvertiser.scala:48)
at org.apache.spark.rdd.RDD$$anonfun$foreachPartition$1$$anonfun$apply$29.apply(RDD.scala:926)
at org.apache.spark.rdd.RDD$$anonfun$foreachPartition$1$$anonfun$apply$29.apply(RDD.scala:926)
at org.apache.spark.SparkContext$$anonfun$runJob$5.apply(SparkContext.scala:2069)
at org.apache.spark.SparkContext$$anonfun$runJob$5.apply(SparkContext.scala:2069)
at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:87)
at org.apache.spark.scheduler.Task.run(Task.scala:108)
at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:338)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

Driver stacktrace:

超凡天赐 发表于 2018-8-1 10:18:09

您好
您的这个错误并不是因为缺失java类,如果是这个错误,就会出现出现java.lang.ClassNotFoundException这种情况。应该是ClassLoader在读取类时遇到了错误。建议您在static代码块中放入try去捕捉错误。

static {
try {

    ... your init code here

} catch (Throwable t) {
    LOG.error("Failure during static initialization", t);
    throw t;
}
}

我认为您有可能是类的路径写错了,或者其他原因。
Could not initialize class io.grpc.netty.Utils
页: [1]
查看完整版本: Spark Streaming 中使用grpc ,在服务器上运行时报错