IllegalAccessError: tried to access field com.google.protobuf.AbstractMessage.memoizedSize while using KMS decrypt
IllegalAccessError: tried to access field com.google.protobuf.AbstractMessage.memoizedSize while using KMS decrypt
尝试使用 Google KMS SDK 版本 1.40.0
解密密码字符串时遇到以下错误。
使用的代码:
try (KeyManagementServiceClient keyManagementServiceClient = KeyManagementServiceClient.create()) {
CryptoKeyName name = CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]");
ByteString ciphertext = ByteString.copyFromUtf8("");
DecryptResponse response = keyManagementServiceClient.decrypt(name.toString(), ciphertext);
}
错误:
Caused by: java.lang.IllegalAccessError: tried to access field com.google.protobuf.AbstractMessage.memoizedSize from class com.google.cloud.kms.v1.DecryptRequest
at com.google.cloud.kms.v1.DecryptRequest.getSerializedSize(DecryptRequest.java:472)
at io.grpc.protobuf.lite.ProtoInputStream.available(ProtoInputStream.java:108)
at io.grpc.internal.MessageFramer.getKnownLength(MessageFramer.java:205)
at io.grpc.internal.MessageFramer.writePayload(MessageFramer.java:137)
at io.grpc.internal.AbstractStream.writeMessage(AbstractStream.java:65)
at io.grpc.internal.ForwardingClientStream.writeMessage(ForwardingClientStream.java:37)
at io.grpc.internal.ClientCallImpl.sendMessageInternal(ClientCallImpl.java:544)
at io.grpc.internal.ClientCallImpl.sendMessage(ClientCallImpl.java:528)
at io.grpc.ForwardingClientCall.sendMessage(ForwardingClientCall.java:37)
at io.grpc.stub.ClientCalls.asyncUnaryRequestCall(ClientCalls.java:308)
at io.grpc.stub.ClientCalls.futureUnaryCall(ClientCalls.java:218)
at com.google.api.gax.grpc.GrpcDirectCallable.futureCall(GrpcDirectCallable.java:58)
at com.google.api.gax.grpc.GrpcUnaryRequestParamCallable.futureCall(GrpcUnaryRequestParamCallable.java:65)
at com.google.api.gax.grpc.GrpcExceptionCallable.futureCall(GrpcExceptionCallable.java:64)
at com.google.api.gax.rpc.AttemptCallable.call(AttemptCallable.java:86)
at com.google.api.gax.rpc.RetryingCallable.futureCall(RetryingCallable.java:63)
at com.google.api.gax.rpc.RetryingCallable.futureCall(RetryingCallable.java:41)
at com.google.api.gax.tracing.TracedUnaryCallable.futureCall(TracedUnaryCallable.java:75)
at com.google.api.gax.rpc.UnaryCallable.futureCall(UnaryCallable.java:126)
at com.google.api.gax.rpc.UnaryCallable.futureCall(UnaryCallable.java:87)
... 27 more
请帮忙。
这是因为您在 class路径中有不同版本的 protobuf。使用一些阴影插件重命名最终构建 jar 中的原型 class。
示例 sbt(程序集) ::: https://github.com/sbt/sbt-assembly#shading
assemblyShadeRules in assembly := Seq(
ShadeRule.rename("com.google.protobuf.**" -> "shade.protobuf.@1").inAll,
)
尝试使用 Google KMS SDK 版本 1.40.0
解密密码字符串时遇到以下错误。
使用的代码:
try (KeyManagementServiceClient keyManagementServiceClient = KeyManagementServiceClient.create()) {
CryptoKeyName name = CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]");
ByteString ciphertext = ByteString.copyFromUtf8("");
DecryptResponse response = keyManagementServiceClient.decrypt(name.toString(), ciphertext);
}
错误:
Caused by: java.lang.IllegalAccessError: tried to access field com.google.protobuf.AbstractMessage.memoizedSize from class com.google.cloud.kms.v1.DecryptRequest
at com.google.cloud.kms.v1.DecryptRequest.getSerializedSize(DecryptRequest.java:472)
at io.grpc.protobuf.lite.ProtoInputStream.available(ProtoInputStream.java:108)
at io.grpc.internal.MessageFramer.getKnownLength(MessageFramer.java:205)
at io.grpc.internal.MessageFramer.writePayload(MessageFramer.java:137)
at io.grpc.internal.AbstractStream.writeMessage(AbstractStream.java:65)
at io.grpc.internal.ForwardingClientStream.writeMessage(ForwardingClientStream.java:37)
at io.grpc.internal.ClientCallImpl.sendMessageInternal(ClientCallImpl.java:544)
at io.grpc.internal.ClientCallImpl.sendMessage(ClientCallImpl.java:528)
at io.grpc.ForwardingClientCall.sendMessage(ForwardingClientCall.java:37)
at io.grpc.stub.ClientCalls.asyncUnaryRequestCall(ClientCalls.java:308)
at io.grpc.stub.ClientCalls.futureUnaryCall(ClientCalls.java:218)
at com.google.api.gax.grpc.GrpcDirectCallable.futureCall(GrpcDirectCallable.java:58)
at com.google.api.gax.grpc.GrpcUnaryRequestParamCallable.futureCall(GrpcUnaryRequestParamCallable.java:65)
at com.google.api.gax.grpc.GrpcExceptionCallable.futureCall(GrpcExceptionCallable.java:64)
at com.google.api.gax.rpc.AttemptCallable.call(AttemptCallable.java:86)
at com.google.api.gax.rpc.RetryingCallable.futureCall(RetryingCallable.java:63)
at com.google.api.gax.rpc.RetryingCallable.futureCall(RetryingCallable.java:41)
at com.google.api.gax.tracing.TracedUnaryCallable.futureCall(TracedUnaryCallable.java:75)
at com.google.api.gax.rpc.UnaryCallable.futureCall(UnaryCallable.java:126)
at com.google.api.gax.rpc.UnaryCallable.futureCall(UnaryCallable.java:87)
... 27 more
请帮忙。
这是因为您在 class路径中有不同版本的 protobuf。使用一些阴影插件重命名最终构建 jar 中的原型 class。
示例 sbt(程序集) ::: https://github.com/sbt/sbt-assembly#shading
assemblyShadeRules in assembly := Seq(
ShadeRule.rename("com.google.protobuf.**" -> "shade.protobuf.@1").inAll,
)