Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to load credentials #227

Open
zola33dsf opened this issue Mar 16, 2023 · 3 comments
Open

Unable to load credentials #227

zola33dsf opened this issue Mar 16, 2023 · 3 comments

Comments

@zola33dsf
Copy link

Hello,
I'm using aws-kcl v2.2.2 with node js v19.6.0
When i run the node_modules/aws-kcl/bin/kcl-boostrap file i have this issue :

Starting MultiLangDaemon ... java.lang.RuntimeException: java.lang.reflect.InvocationTargetException at software.amazon.kinesis.multilang.config.KinesisClientLibConfigurator.lambda$getConfiguration$0(KinesisClientLibConfigurator.java:67) at java.base/java.lang.Iterable.forEach(Iterable.java:75) at java.base/java.util.Collections$SynchronizedCollection.forEach(Collections.java:2067) at software.amazon.kinesis.multilang.config.KinesisClientLibConfigurator.getConfiguration(KinesisClientLibConfigurator.java:63) at software.amazon.kinesis.multilang.MultiLangDaemonConfig.<init>(MultiLangDaemonConfig.java:108) at software.amazon.kinesis.multilang.MultiLangDaemonConfig.<init>(MultiLangDaemonConfig.java:81) at software.amazon.kinesis.multilang.MultiLangDaemonConfig.<init>(MultiLangDaemonConfig.java:65) at software.amazon.kinesis.multilang.MultiLangDaemon.buildMultiLangDaemonConfig(MultiLangDaemon.java:171) at software.amazon.kinesis.multilang.MultiLangDaemon.main(MultiLangDaemon.java:220) Caused by: java.lang.reflect.InvocationTargetException at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.apache.commons.beanutils.PropertyUtilsBean.invokeMethod(PropertyUtilsBean.java:2128) at org.apache.commons.beanutils.PropertyUtilsBean.setSimpleProperty(PropertyUtilsBean.java:2109) at org.apache.commons.beanutils.PropertyUtilsBean.setNestedProperty(PropertyUtilsBean.java:1915) at org.apache.commons.beanutils.PropertyUtilsBean.setProperty(PropertyUtilsBean.java:2022) at org.apache.commons.beanutils.BeanUtilsBean.setProperty(BeanUtilsBean.java:1018) at software.amazon.kinesis.multilang.config.KinesisClientLibConfigurator.lambda$getConfiguration$0(KinesisClientLibConfigurator.java:65) ... 8 more Caused by: java.lang.IllegalArgumentException: No credential providers specified at com.amazonaws.auth.AWSCredentialsProviderChain.<init>(AWSCredentialsProviderChain.java:59) at software.amazon.kinesis.multilang.config.AWSCredentialsProviderPropertyValueDecoder.decodeValue(AWSCredentialsProviderPropertyValueDecoder.java:57) at software.amazon.kinesis.multilang.config.MultiLangDaemonConfiguration.lambda$new$0(MultiLangDaemonConfiguration.java:249) at software.amazon.kinesis.multilang.config.BuilderDynaBean.set(BuilderDynaBean.java:258) at software.amazon.kinesis.multilang.config.MultiLangDaemonConfiguration.setAWSCredentialsProvider(MultiLangDaemonConfiguration.java:176) ... 18 more java.lang.reflect.InvocationTargetException

And the AWSCredentialsProvider value in my properties file is like this :

AWSCredentialsProvider = STSAssumeRoleSessionCredentialsProvider|arn:aws:iam::955*********:role/FakeRoleForGithub**********|session2

Do someone have the same problem ?
Please let me know 👍

@mnaveenraju
Copy link

Hi,
Same issue for me as well

Starting MultiLangDaemon ...
2023-06-13 15:22:03,416 [main] INFO s.a.k.m.MultiLangDaemonConfig [NONE] - Using a cached thread pool.
2023-06-13 15:22:03,428 [main] INFO s.a.k.m.MultiLangDaemonConfig [NONE] - Running application to process stream scb_input with executable node sample_kcl_app.js
2023-06-13 15:22:03,436 [main] INFO s.a.k.m.MultiLangDaemonConfig [NONE] - Using workerId: 03d3f82d-72f3-4e29-9ff4-56cc1610ab6a
2023-06-13 15:22:03,436 [main] INFO s.a.k.m.MultiLangDaemonConfig [NONE] - MultiLangDaemon is adding the following fields to the User Agent: amazon-kinesis-client-library-java amazon-kinesis-multi-lang-daemon/1.0.1 nodejs/16.16 node
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at software.amazon.kinesis.multilang.config.DynaBeanBuilderSupport.build(DynaBeanBuilderSupport.java:237)
at software.amazon.kinesis.multilang.config.BuilderDynaBean.build(BuilderDynaBean.java:149)
at software.amazon.kinesis.multilang.config.MultiLangDaemonConfiguration.resolvedConfiguration(MultiLangDaemonConfiguration.java:369)
at software.amazon.kinesis.multilang.config.MultiLangDaemonConfiguration.build(MultiLangDaemonConfiguration.java:403)
at software.amazon.kinesis.multilang.MultiLangDaemon.buildScheduler(MultiLangDaemon.java:120)
at software.amazon.kinesis.multilang.MultiLangDaemon.main(MultiLangDaemon.java:222)
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:119)
at java.base/java.lang.reflect.Method.invoke(Method.java:578)
at software.amazon.kinesis.multilang.config.DynaBeanBuilderSupport.build(DynaBeanBuilderSupport.java:235)
... 5 more
Caused by: java.lang.NoClassDefFoundError: io/netty/handler/ssl/SslContext
at software.amazon.awssdk.http.nio.netty.NettyNioAsyncHttpClient.resolveSslProvider(NettyNioAsyncHttpClient.java:161)
at software.amazon.awssdk.http.nio.netty.NettyNioAsyncHttpClient.(NettyNioAsyncHttpClient.java:104)
at software.amazon.awssdk.http.nio.netty.NettyNioAsyncHttpClient.(NettyNioAsyncHttpClient.java:67)
at software.amazon.awssdk.http.nio.netty.NettyNioAsyncHttpClient$DefaultBuilder.buildWithDefaults(NettyNioAsyncHttpClient.java:729)
at software.amazon.awssdk.core.client.builder.SdkDefaultClientBuilder.lambda$null$8(SdkDefaultClientBuilder.java:359)
at java.base/java.util.Optional.map(Optional.java:260)
at software.amazon.awssdk.utils.Either.lambda$map$0(Either.java:51)
at java.base/java.util.Optional.orElseGet(Optional.java:364)
at software.amazon.awssdk.utils.Either.map(Either.java:51)
at software.amazon.awssdk.core.client.builder.SdkDefaultClientBuilder.lambda$resolveAsyncHttpClient$9(SdkDefaultClientBuilder.java:359)
at java.base/java.util.Optional.map(Optional.java:260)
at software.amazon.awssdk.core.client.builder.SdkDefaultClientBuilder.resolveAsyncHttpClient(SdkDefaultClientBuilder.java:359)
at software.amazon.awssdk.core.client.builder.SdkDefaultClientBuilder.finalizeAsyncConfiguration(SdkDefaultClientBuilder.java:299)
at software.amazon.awssdk.core.client.builder.SdkDefaultClientBuilder.asyncClientConfiguration(SdkDefaultClientBuilder.java:210)
at software.amazon.awssdk.services.kinesis.DefaultKinesisAsyncClientBuilder.buildClient(DefaultKinesisAsyncClientBuilder.java:37)
at software.amazon.awssdk.services.kinesis.DefaultKinesisAsyncClientBuilder.buildClient(DefaultKinesisAsyncClientBuilder.java:25)
at software.amazon.awssdk.core.client.builder.SdkDefaultClientBuilder.build(SdkDefaultClientBuilder.java:148)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
... 7 more
Caused by: java.lang.ClassNotFoundException: io.netty.handler.ssl.SslContext
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 25 more
java.lang.reflect.InvocationTargetException
Usage: amazon-kinesis-client MultiLangDaemon [options]
Options:
-l, --log-configuration
File location of logback.xml to be override the default
-p, --properties-file
Properties file to be used with the KCL

For more information, visit: https://github.com/awslabs/amazon-kinesis-client

@gavinvangent
Copy link

gavinvangent commented Aug 11, 2023

From what I can tell, the java side of the kcl uses reflection to find and load resources from your .properties file. This config:

AWSCredentialsProvider = STSAssumeRoleSessionCredentialsProvider|arn:aws:iam::955*********:role/FakeRoleForGithub**********|session2

lets the process know that it should find a class with the name STSAssumeRoleSessionCredentialsProvider and construct a new instance with arn:aws:iam::955*********:role/FakeRoleForGithub********** being the first argument, and session2 being the second argument passed into the constructor.

I assume that the process can't locate a class called STSAssumeRoleSessionCredentialsProvider and fails to load any credentials and then throws the No credentials found error.

Here's what I did, but please make sure you don't just use this blindly:

1 - I downloaded the java aws-sdk .jar file and stored it locally.
2- I then copied the jar file into my docker container:

COPY ./docker/aws-java-sdk-1.12.496.jar ./java/aws-java-sdk-1.12.496.jar

3 - I then edited my npm script to tell it where my java files are:

# Notice the `--java ./java`
npx kcl-bootstrap -p ./docker/kinesis.properties --jar-path ./java -e

4 - I modified my AWSCredentialsProvider variable in the properties file:

AWSCredentialsProvider=com.amazonaws.auth.STSAssumeRoleSessionCredentialsProvider|{arn}|{sessionName}

So in your case it would be:

AWSCredentialsProvider=com.amazonaws.auth.STSAssumeRoleSessionCredentialsProvider|arn:aws:iam::955*********:role/FakeRoleForGithub**********|session2

I'm not a java guru and it took me loads of reading up to get to this solution, so if i've done anything wrong, please let me know. Hope this helps you

@alexunivar
Copy link

But even if you use default one from example:
AWSCredentialsProvider = DefaultAWSCredentialsProviderChain
It still gives you the same error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants