spark-submit protobuf openrtb java.lang.VerifyError



>我在 s3 上有 gzip 文件,文件包含编码的 Base64 字符串,表示 protobuf 消息的字节数组。 原型方案如下所示:

syntax = "proto2";
package com.myproject.proto;
option java_outer_classname = "MyProtos";
import "openrtb.proto";
message Request {
optional int64 timestamp = 1;
optional com.google.openrtb.BidRequest bidRequest = 2;
optional string otherData = 3;
}

当我从本地运行 flatMap 函数的下一个火花代码时:

public static Iterator<MyProtos.Request> parseRequest(String source) {
try {
byte[] bytes = Base64.decodeBase64(source);
MyProtos.Request request = MyProtos.Request.parseFrom(bytes);
return Collections.singletonList(request).iterator();
} catch (Exception e) {
return Collections.emptyIterator();
}
}

一切都很好,但是当我尝试通过 spark-submit 在远程上运行此代码时,我遇到了异常:

java.lang.VerifyError: Bad type on operand stack
Exception Details:
Location:
com/google/protobuf/GeneratedMessageV3$ExtendableMessage.hasExtension(Lcom/google/protobuf/GeneratedMessage$GeneratedExtension;)Z @2: invokevirtual
Reason:
Type 'com/google/protobuf/GeneratedMessage$GeneratedExtension' (current frame, stack[1]) is not assignable to 'com/google/protobuf/ExtensionLite'
Current Frame:
bci: @2
flags: { }
locals: { 'com/google/protobuf/GeneratedMessageV3$ExtendableMessage', 'com/google/protobuf/GeneratedMessage$GeneratedExtension' }
stack: { 'com/google/protobuf/GeneratedMessageV3$ExtendableMessage', 'com/google/protobuf/GeneratedMessage$GeneratedExtension' }
Bytecode:
0x0000000: 2a2b b600 21ac

就我而言,问题是该应用程序是使用 protobuf 3.5.0 构建的,但 Spark 在罐子目录中有 2.5.0。 简单的解决方案是将新的 3.5.0 罐子放进去。

问题出在运行时环境变量中spark.executor.userClassPathFirst默认情况下等于 false。 如果在客户端模式下远程或本地运行 spark,则不存在此类依赖项冲突问题。

最新更新