Getting exception while trying to build SsmClient from aws-sdk-java version 2

0 votes

The exception I am getting --

java.lang.NoClassDefFoundError: org/apache/http/impl/client/DefaultClientConnectionReuseStrategy
at org.jboss.resteasy.core.ExceptionHandler.handleApplicationException(ExceptionHandler.java:76)
  at org.jboss.resteasy.core.ExceptionHandler.handleException(ExceptionHandler.java:212)
  at org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:166)
  at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:393)
  at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:200)
  at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:220)
  at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)
  at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)

The code block where exception is occurring --

//The region value being passed is "us-east-1" and paramKeyPath is the key present in aws systems //manager.
public String getParameterUsingAwsSSM(String paramKeyPath, String region) throws Exception {
        String paramKeyValue = null;
        System.out.println("Key path in AWS systems manager :: " + paramKeyPath);
        try {
            Region newRegion = Region.of(region);
                        //The below line gets printed---
            System.out.println("Region:: " + newRegion);
                        //Exception occurs in below line most probably---
            SsmClient ssmClient = SsmClient.builder().region(newRegion).build();
                        //The below line doesn't get printed---
            System.out.println("successfully got ssmclient");
            GetParameterRequest parameterRequest = GetParameterRequest.builder().name(paramKeyPath)
                    .withDecryption(Boolean.TRUE).build();
            System.out.println("successfully parameterRequest fetched");
            GetParameterResponse parameterResponse = ssmClient.getParameter(parameterRequest);
            System.out.println("successfully parameterResponse fetched");
            paramKeyValue = parameterResponse.parameter().value();
            System.out.println("The value of param is ::: "+
                    parameterResponse.parameter().value());
        } catch (Exception exception) {
            System.out.println("Exception from getParameterUsingAwsSSM() : "+ exception);
            throw exception;
        }
        return paramKeyValue;
    }

The dependencies I have added in my pom.xml --

<dependencies>
        <dependency>
            <!-- this is an upgrade from 3.0-rc4 -->
            <groupId>commons-httpclient</groupId>
            <artifactId>commons-httpclient</artifactId>
            <version>3.0</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.30</version>
        </dependency>
        <dependency>
            <groupId>software.amazon.awssdk</groupId>
            <artifactId>cloudfront</artifactId>
            <version>2.19.15</version>
        </dependency>
        <dependency>
            <groupId>org.bouncycastle</groupId>
            <artifactId>bcprov-jdk18on</artifactId>
            <version>1.72</version>
        </dependency>
        <dependency>
            <groupId>org.bouncycastle</groupId>
            <artifactId>bcpkix-jdk18on</artifactId>
            <version>1.72</version>
        </dependency>
        <dependency>
            <groupId>software.amazon.awssdk</groupId>
            <artifactId>regions</artifactId>
            <version>2.19.15</version>
        </dependency>
        <dependency>
            <groupId>software.amazon.awssdk</groupId>
            <artifactId>ssm</artifactId>
            <version>2.19.15</version>
        </dependency>
    </dependencies>

Can someone please help me with this? I have been stuck in this since 3 days.

I was expecting to get the parameter value from aws parameter store but I am getting the above mentioned exception, I tried adding org.apache.httpcomponents.httpclient dependency also to my project but still not working.

Jan 24, 2023 in AWS by Tejashwini
• 3,820 points
685 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In AWS

+3 votes
3 answers
0 votes
1 answer
0 votes
1 answer

AWS S3 CLI : error while trying to copy files locally using terminal

For the first error you should add ...READ MORE

answered Aug 3, 2018 in AWS by Archana
• 4,170 points
11,405 views
0 votes
1 answer

How to invoke the AWS lambda function from Java code

There are 2 methods in this class which should ...READ MORE

answered Feb 19, 2019 in AWS by Archana
• 5,640 points
6,019 views
0 votes
1 answer

How to create a EMR Cluster using Java AWS SDK?

The Java code for creating an AWS ...READ MORE

answered Feb 27, 2019 in AWS by Priyaj
• 58,020 points
1,590 views
+2 votes
1 answer

Deploy Docker Containers from Docker Cloud

To solve this problem, I followed advice ...READ MORE

answered Sep 3, 2018 in AWS by Priyaj
• 58,020 points
2,714 views
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
4,034 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP