java - Java KeyManagementServiceClient 创建在 Jruby 中挂起
问题描述
我在运行良好(单元测试)的 java 文件(GcpEncrypt.java)中有以下块。
但是,当我将其 jar 并从 a 中调用它时logstash Jruby input plugin
,它会挂在客户端创建部分。
public byte[] decryptWrappedKey(String wrappedKey, String cid)
throws IOException {
if (this.testMode) { logger.log(Level.INFO, "Decrypting wrapped key");}
byte[] wrappedKeyBytes = Base64.decodeBase64(wrappedKey);
// Create the KeyManagementServiceClient using try-with-resources to manage client cleanup.
if (this.testMode) { logger.log(Level.INFO, "Creating KMS Client ...");}
try {
KeyManagementServiceClient client = KeyManagementServiceClient.create();
logger.log(Level.INFO, "ENTERED KEY CREATION");
String keyResourceName = CryptoKeyName.format(
this.projectId,
this.locationId,
this.keyRingId,
cid);
// Decrypt the ciphertext with Cloud KMS.
if (this.testMode) { logger.log(Level.INFO, "Decrypting KMS response"); }
DecryptResponse response = client.decrypt(keyResourceName, ByteString.copyFrom(wrappedKeyBytes));
if (this.testMode) { logger.log(Level.INFO, "Returning decrypted wraped key"); }
client.close();
logger.log(Level.INFO, "**************CLOSING KMS CLIENT ***********");
return response.getPlaintext().toByteArray();
}catch (Exception e) {
throw new RuntimeException(e);
}
}
我可以看到ENTERED KEY CREATION
日志,然后它就挂了,我该如何调试呢?
编辑
KeyManagementServiceClient
通过将 实例化为实例变量,我能够找到相关的。似乎'com.google.cloud', 'google-cloud-kms', '0.81.0-beta'
罐子缺少com/google/cloud/kms/v1/ListKeyRingsRequest
课程。
java.lang.NoClassDefFoundError: com/google/cloud/kms/v1/ListKeyRingsRequest
at com.google.cloud.kms.v1.stub.GrpcKeyManagementServiceStub.<clinit>(com/google/cloud/kms/v1/stub/GrpcKeyManagementServiceStub.java:88)
at com.google.cloud.kms.v1.stub.KeyManagementServiceStubSettings.createStub(com/google/cloud/kms/v1/stub/KeyManagementServiceStubSetting
s.java:292)
at com.google.cloud.kms.v1.KeyManagementServiceClient.<init>(com/google/cloud/kms/v1/KeyManagementServiceClient.java:154)
at com.google.cloud.kms.v1.KeyManagementServiceClient.create(com/google/cloud/kms/v1/KeyManagementServiceClient.java:135)
at com.google.cloud.kms.v1.KeyManagementServiceClient.create(com/google/cloud/kms/v1/KeyManagementServiceClient.java:126)
解决方案
推荐阅读
- electron-react-boilerplate - 不能做圆角
- go - 主机参数在 mux.Vars() 中不可用
- python - 如何按升序打印输出?
- java - 在 jsp 的类中找不到属性,即使它存在
- apache-spark - Hadoop S3 配置无法在 Cloudera 环境中运行的 Spark 会话上设置 (CDH 6.3.0)
- php - 将状态百分比添加到刀片中的进度条
- javascript - 世博相机内的焦点形状
- graphql - 当我指定新的输入类型时,FaunaDB GraphiQL 将不允许我更新我的架构
- python - 使用自定义更改管理表单字段
- android - 为什么我在Android Studio中设置了标题后工具栏的标题不显示?