java.lang.NoClassDefFoundError: software.amazon.awssdk.auth.credentials.AwsCredentials - Stack Overflow

I have no references to the above class in my code. I am using software.amazon.awssdk.auth.credentials.

I have no references to the above class in my code. I am using software.amazon.awssdk.auth.credentials.AwsCredentialsProvider class in my code. I still see the error. Background: I am trying to establish a connection to DocDB Client. There are 2 different jars for the docdb client. One to establish a connection through test connection is in Jar a.jar. When I go through this logic it passes I am able to establish a connection. Same logic is call from jar b.jar which makes a call to the code in a.jar to establish the connection. It fails with class not found exception seen below. Class b from b.jar is just making a call to class a from a.jar to establish the connection. I am unable to figure this one out. Any help?

I have below jars referenced in both the packages

Call to below code fails when called from an external jar, call from within the same jar succeeds.

import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider;
AwsCredentialsProvider getAwsCredentialsProvider() throws Exception {
        
        AwsSecretsManagerConfig conf = null;
        try {
            conf = this.ds.getAwsSecretsManagerConfig();
        } catch (Exception e) {
            throw new Exception("failed Connection");               
        }
        String accessId = "";
        String secreteAccessKey = "";
        try {
            accessId = conf.getDecryptedAccessId();
        } catch (Exception e1) {
            throw new throw new Exception("failed Connection");
        }
        try {
            secreteAccessKey = conf.getDecryptedSecretAccessKey();
        } catch (Exception e1) {
            throw new Exception("failed Connection");
        }
        
        //get aws connection configuration
        AwsSecretManagerConnectionConfig connectConfig = new AwsSecretManagerConnectionConfig(accessId,secreteAccessKey,conf.getAuthType(),datasource.getRegionName(),conf.getRoleArn());
        String awsVariables = "accessId: " + accessId + " ,secreteAccessKey: " + secreteAccessKey +
                    " ,conf.getAuthType(): " + conf.getAuthType() + " ,datasource.getRegionName(): " 
                + datasource.getRegionName() + " ,conf.getRoleArn(); " + conf.getRoleArn(); 
        System.out.println("inside db class method getAwsCredentialsProvider awsVariables - " + awsVariables);
        return AWSAuthenticationUtil.buildAWSCredentialsProvider(connectConfig);
    }
Exception stacktrace :
Caused by: java.lang.ClassNotFoundException: software.amazon.awssdk.auth.credentials.AwsCredentials
        at java.URLClassLoader.findClass(URLClassLoader.java:610) ~[?:1.8.0]
        at java.lang.ClassLoader.loadClassHelper(ClassLoader.java:948) ~[?:2.9 (09-08-2023)]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:893) ~[?:2.9 (09-08-2023)]
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:353) ~[?:1.8.0]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:876) ~[?:2.9 (09-08-2023)]
        ... 11 more

I verified the external jars being used by these jars. They are both identical lists.

I added log statements before establish connection. when called directly to a.jar for connection it is successful, but when called through b.jar is it failing with above exception.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744394658a4572078.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信