我正在尝试使用AWS CodeGuru Profiler,由于某种原因,我遇到了以下异常
04-15-2020 11:51:09 [Amazon-Profiler] INFO software.amazon.codeguruprofilerjavaagent.CodeGuruProfilerSDKClient [configureAgent:69] - Exception while calling agent orchestration.
java.lang.NullPointerException: Credentials must not be null.
at software.amazon.awssdk.utils.Validate.paramNotNull(Validate.java:117)
at software.amazon.awssdk.auth.signer.params.Aws4SignerParams.<init>(Aws4SignerParams.java:42)
at software.amazon.awssdk.auth.signer.params.Aws4SignerParams$BuilderImpl.build(Aws4SignerParams.java:206)
at software.amazon.awssdk.auth.signer.internal.BaseAws4Signer.sign(BaseAws4Signer.java:34)
at software.amazon.awssdk.core.internal.http.pipeline.stages.SigningStage.signRequest(SigningStage.java:63)```
This is my code
new Profiler.Builder()
.profilingGroupName("codeguru-profiling")
.build().start();
答案 0 :(得分:0)
如果未设置awsCredentialsProvider,则应该获得默认值。默认值将由AWS凭证链确定 https://docs.aws.amazon.com/sdk-for-java/v2/developer-guide/credentials.html
仔细检查您的凭据是否可以通过其中一种方法使用(例如设置环境变量)。
这可能是CodeGuru SDK中的错误,毕竟这是非常新的。在这种情况下,您可以直接设置凭据:
new Profiler.Builder().profilingGroupName("my-profiling-group")
.awsCredentialsProvider(new EnvironmentVariableCredentialsProvider()).build().start();
答案 1 :(得分:0)
因此将awssdk从2.11.12降级到2.10.28解决了该问题。 我不知道为什么!