aws / aws-sdk-java

The official AWS SDK for Java 1.x (In Maintenance Mode, End-of-Life on 12/31/2025). The AWS SDK for Java 2.x is available here: https://github.com/aws/aws-sdk-java-v2/
https://aws.amazon.com/sdkforjava
Apache License 2.0
4.13k stars 2.83k forks source link

Exception while Java application is trying to communicate to Dynamo DB #1638

Closed DXTCODES closed 6 years ago

DXTCODES commented 6 years ago

I'm using below dependency in my project

com.amazonaws aws-java-sdk 1.11.349

Exception in thread "main" java.lang.NoSuchMethodError: org.apache.http.conn.ssl.SSLConnectionSocketFactory.(Ljavax/net/ssl/SSLContext;Ljavax/net/ssl/HostnameVerifier;)V at com.amazonaws.http.conn.ssl.SdkTLSSocketFactory.(SdkTLSSocketFactory.java:58) at com.amazonaws.http.apache.client.impl.ApacheConnectionManagerFactory.getPreferredSocketFactory(ApacheConnectionManagerFactory.java:90) at com.amazonaws.http.apache.client.impl.ApacheConnectionManagerFactory.create(ApacheConnectionManagerFactory.java:63) at com.amazonaws.http.apache.client.impl.ApacheConnectionManagerFactory.create(ApacheConnectionManagerFactory.java:56) at com.amazonaws.http.apache.client.impl.ApacheHttpClientFactory.create(ApacheHttpClientFactory.java:50) at com.amazonaws.http.apache.client.impl.ApacheHttpClientFactory.create(ApacheHttpClientFactory.java:38) at com.amazonaws.http.AmazonHttpClient.(AmazonHttpClient.java:315) at com.amazonaws.http.AmazonHttpClient.(AmazonHttpClient.java:299) at com.amazonaws.AmazonWebServiceClient.(AmazonWebServiceClient.java:169) at com.amazonaws.AmazonWebServiceClient.(AmazonWebServiceClient.java:158) at com.amazonaws.AmazonWebServiceClient.(AmazonWebServiceClient.java:143) at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.(AmazonDynamoDBClient.java:239) at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.(AmazonDynamoDBClient.java:218) at com.self.DynamoTest.DynamoDBClient.(DynamoDBClient.java:57) at com.self.DynamoTest.DynamoDBClient.main(DynamoDBClient.java:364)

DXTCODES commented 6 years ago

I've passed in accessKey and secretKey also

dagnir commented 6 years ago

Hi @DXTCODES, looking at the stacktrace it appears you have an incompatible version of the Apache HTTP Client on your classpath. Can you ensure that you're using at least version 4.5.5 in your project? https://github.com/aws/aws-sdk-java/blob/29b4d07239f66a95d6faeb3907624573316684ec/pom.xml#L213

You can run mvn dependency:tree from your project root to show all the artifacts that are being pulled in.

DXTCODES commented 6 years ago

I've included

4.5.5 in my pom but yet I get the same issue. I've checked with running `mvn dependency:tree` but I'm not sure which dependency should I have to look for after I run the command
dagnir commented 6 years ago

Hi @DXTCODES Please don't post your access keys on GitHub since that would allow anyone seeing your comment to use that IAM user.

I've gone ahead and Deleted your comment. Please also immediately rotate your keys and disable that access key immediately.

dagnir commented 6 years ago

Regarding your follow up question, sorry my answer was pretty vague.

I meant that if you have a dependency on a different version of httpclient in your POM, to make sure that's it at least version 4.5.5.

Can you run mvn dependency:tree so we can see what modules are being included in your project?

DXTCODES commented 6 years ago

@dagnir I'm actually trying to connect to DynamoDB table from my Java Application . My Dynamo DB Console is not the local URL . The console is the enterprise one . I need some help in how to connect. Please let me know if you have any info on that.

I ran the mvn dependency:tree command the below are the results

[INFO] Scanning for projects... [INFO]
[INFO] ------------------------------------------------------------------------ [INFO] Building DynamoTest 0.0.1-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-dependency-plugin:2.9:tree (default-cli) @ DynamoTest --- [INFO] com.self:DynamoTest:jar:0.0.1-SNAPSHOT [INFO] +- com.amazonaws:aws-java-sdk:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-eks:jar:1.11.349:compile [INFO] | | - com.amazonaws:jmespath-java:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-mediatailor:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-neptune:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-pi:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-iot1clickprojects:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-iot1clickdevices:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-iotanalytics:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-acmpca:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-secretsmanager:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-fms:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-connect:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-transcribe:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-autoscalingplans:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-workmail:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-servicediscovery:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-cloud9:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-serverlessapplicationrepository:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-alexaforbusiness:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-resourcegroups:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-comprehend:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-translate:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-sagemaker:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-iotjobsdataplane:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-sagemakerruntime:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-kinesisvideo:jar:1.11.349:compile [INFO] | | +- io.netty:netty-codec-http:jar:4.1.17.Final:compile [INFO] | | | - io.netty:netty-codec:jar:4.1.17.Final:compile [INFO] | | - io.netty:netty-handler:jar:4.1.17.Final:compile [INFO] | | +- io.netty:netty-buffer:jar:4.1.17.Final:compile [INFO] | | | - io.netty:netty-common:jar:4.1.17.Final:compile [INFO] | | - io.netty:netty-transport:jar:4.1.17.Final:compile [INFO] | | - io.netty:netty-resolver:jar:4.1.17.Final:compile [INFO] | +- com.amazonaws:aws-java-sdk-appsync:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-guardduty:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-mq:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-mediaconvert:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-mediastore:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-mediastoredata:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-medialive:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-mediapackage:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-costexplorer:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-pricing:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-mobile:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-cloudhsmv2:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-glue:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-migrationhub:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-dax:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-greengrass:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-athena:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-marketplaceentitlement:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-codestar:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-lexmodelbuilding:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-resourcegroupstaggingapi:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-pinpoint:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-xray:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-opsworkscm:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-support:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-simpledb:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-servicecatalog:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-servermigration:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-simpleworkflow:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-storagegateway:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-route53:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-s3:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-importexport:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-sts:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-sqs:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-rds:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-redshift:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-elasticbeanstalk:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-glacier:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-iam:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-datapipeline:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-elasticloadbalancing:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-elasticloadbalancingv2:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-emr:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-elasticache:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-elastictranscoder:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-ec2:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-dynamodb:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-sns:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-budgets:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-cloudtrail:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-cloudwatch:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-logs:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-events:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-cognitoidentity:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-cognitosync:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-directconnect:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-cloudformation:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-cloudfront:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-clouddirectory:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-kinesis:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-opsworks:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-ses:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-autoscaling:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-cloudsearch:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-cloudwatchmetrics:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-codedeploy:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-codepipeline:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-kms:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-config:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-lambda:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-ecs:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-ecr:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-cloudhsm:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-ssm:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-workspaces:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-machinelearning:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-directory:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-efs:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-codecommit:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-devicefarm:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-elasticsearch:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-waf:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-marketplacecommerceanalytics:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-inspector:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-iot:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-api-gateway:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-acm:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-gamelift:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-dms:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-marketplacemeteringservice:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-cognitoidp:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-discovery:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-applicationautoscaling:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-snowball:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-rekognition:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-polly:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-lightsail:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-stepfunctions:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-health:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-costandusagereport:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-codebuild:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-appstream:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-shield:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-batch:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-lex:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-mechanicalturkrequester:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-organizations:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-workdocs:jar:1.11.349:compile [INFO] | +- com.amazonaws:aws-java-sdk-core:jar:1.11.349:compile [INFO] | | +- commons-logging:commons-logging:jar:1.1.3:compile [INFO] | | +- org.apache.httpcomponents:httpclient:jar:4.3.6:compile [INFO] | | | +- org.apache.httpcomponents:httpcore:jar:4.3.3:compile [INFO] | | | - commons-codec:commons-codec:jar:1.6:compile [INFO] | | +- software.amazon.ion:ion-java:jar:1.0.2:compile [INFO] | | +- com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:jar:2.6.7:compile [INFO] | | - joda-time:joda-time:jar:2.5:compile [INFO] | +- com.amazonaws:aws-java-sdk-models:jar:1.11.349:compile [INFO] | - com.amazonaws:aws-java-sdk-swf-libraries:jar:1.11.22:compile [INFO] +- junit:junit:jar:3.8.1:test [INFO] - org.springframework.boot:spring-boot-starter-web:jar:1.2.2.RELEASE:compile [INFO] +- org.springframework.boot:spring-boot-starter:jar:1.2.2.RELEASE:compile [INFO] | +- org.springframework.boot:spring-boot:jar:1.2.2.RELEASE:compile [INFO] | +- org.springframework.boot:spring-boot-autoconfigure:jar:1.2.2.RELEASE:compile [INFO] | +- org.springframework.boot:spring-boot-starter-logging:jar:1.2.2.RELEASE:compile [INFO] | | +- org.slf4j:jcl-over-slf4j:jar:1.7.10:compile [INFO] | | | - org.slf4j:slf4j-api:jar:1.7.10:compile [INFO] | | +- org.slf4j:jul-to-slf4j:jar:1.7.10:compile [INFO] | | +- org.slf4j:log4j-over-slf4j:jar:1.7.10:compile [INFO] | | - ch.qos.logback:logback-classic:jar:1.1.2:compile [INFO] | | - ch.qos.logback:logback-core:jar:1.1.2:compile [INFO] | - org.yaml:snakeyaml:jar:1.14:compile [INFO] +- org.springframework.boot:spring-boot-starter-tomcat:jar:1.2.2.RELEASE:compile [INFO] | +- org.apache.tomcat.embed:tomcat-embed-core:jar:8.0.20:compile [INFO] | +- org.apache.tomcat.embed:tomcat-embed-el:jar:8.0.20:compile [INFO] | +- org.apache.tomcat.embed:tomcat-embed-logging-juli:jar:8.0.20:compile [INFO] | - org.apache.tomcat.embed:tomcat-embed-websocket:jar:8.0.20:compile [INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.4.5:compile [INFO] | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.4.5:compile [INFO] | - com.fasterxml.jackson.core:jackson-core:jar:2.4.5:compile [INFO] +- org.hibernate:hibernate-validator:jar:5.1.3.Final:compile [INFO] | +- javax.validation:validation-api:jar:1.1.0.Final:compile [INFO] | +- org.jboss.logging:jboss-logging:jar:3.1.3.GA:compile [INFO] | - com.fasterxml:classmate:jar:1.0.0:compile [INFO] +- org.springframework:spring-core:jar:4.1.5.RELEASE:compile [INFO] +- org.springframework:spring-web:jar:4.1.5.RELEASE:compile [INFO] | +- org.springframework:spring-aop:jar:4.1.5.RELEASE:compile [INFO] | | - aopalliance:aopalliance:jar:1.0:compile [INFO] | +- org.springframework:spring-beans:jar:4.1.5.RELEASE:compile [INFO] | - org.springframework:spring-context:jar:4.1.5.RELEASE:compile [INFO] - org.springframework:spring-webmvc:jar:4.1.5.RELEASE:compile [INFO] - org.springframework:spring-expression:jar:4.1.5.RELEASE:compile [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 7.503 s [INFO] Finished at: 2018-06-19T15:10:12-04:00 [INFO] Final Memory: 18M/225M [INFO] ------------------------------------------------------------------------

dagnir commented 6 years ago

Hmm interesting,

[INFO] | +- com.amazonaws:aws-java-sdk-core:jar:1.11.349:compile
[INFO] | | +- commons-logging:commons-logging:jar:1.1.3:compile
[INFO] | | +- org.apache.httpcomponents:httpclient:jar:4.3.6:compile
[INFO] | | | +- org.apache.httpcomponents:httpcore:jar:4.3.3:compile

shows 1.11.349 is pulling in 4.3.6 for some reason.

Can you post your pom.xml as well if possible?

DXTCODES commented 6 years ago

<project

xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

4.0.0 com.self DynamoTest 0.0.1-SNAPSHOT jar DynamoTest http://maven.apache.org
  <properties>
    <maven.compiler.target>1.8</maven.compiler.target>
    <maven.compiler.source>1.8</maven.compiler.source>
    <httpcomponents.httpclient.version>4.5.5</httpcomponents.httpclient.version>
</properties>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.2.2.RELEASE</version>

com.amazonaws aws-java-sdk 1.11.349 junit junit 3.8.1 test org.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-maven-plugin

dagnir commented 6 years ago

Okay I see. It looks like the problem is caused by the parent relationship to spring-boot-starter-parent:1.2.2.RELEASE which is pretty old, and has dependencies on older version of not just the HTTP client but also Jackson and others.

The easiest way to fix this is to use a newer version of spring-boot-starter-parent. Currently, the latest version is 2.0.3.RELEASE

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.3.RELEASE</version>
</parent>
DXTCODES commented 6 years ago

I've put your changes and now I'm getting error at the below line CreateTableResult result = client.createTable(request);

the error is com.amazonaws.services.dynamodbv2.model.AmazonDynamoDBException: null (Service: AmazonDynamoDBv2; Status Code: 407; Error Code: null; Request ID: null) at com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleErrorResponse(AmazonHttpClient.java:1640) at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeOneRequest(AmazonHttpClient.java:1304) at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:1058) at com.amazonaws.http.AmazonHttpClient$RequestExecutor.doExecute(AmazonHttpClient.java:743) at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeWithTimer(AmazonHttpClient.java:717) at com.amazonaws.http.AmazonHttpClient$RequestExecutor.execute(AmazonHttpClient.java:699) at com.amazonaws.http.AmazonHttpClient$RequestExecutor.access$500(AmazonHttpClient.java:667) at com.amazonaws.http.AmazonHttpClient$RequestExecutionBuilderImpl.execute(AmazonHttpClient.java:649) at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:513) at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.doInvoke(AmazonDynamoDBClient.java:3443) at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.invoke(AmazonDynamoDBClient.java:3419) at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.executeCreateTable(AmazonDynamoDBClient.java:956) at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.createTable(AmazonDynamoDBClient.java:931) at com.self.DynamoTest.DynamoDBClient.createTable(DynamoDBClient.java:79) at com.self.DynamoTest.DynamoDBClient.main(DynamoDBClient.java:365)

I'm not sure of the issue

dagnir commented 6 years ago

The 407 HTTP status code is Proxy Authentication Required so it sounds like you're attempting to connect through a proxy and need to provide credentials.

The SDK support connecting through HTTP proxies. You can configure the HTTP proxy host and port, as well as the username and password through the ClientConfiguration object.

Here's a quick example:

        AmazonDynamoDB ddb = AmazonDynamoDBClientBuilder.standard()
                .withClientConfiguration(new ClientConfiguration()
                    .withProxyHost(PROXY_HOST)
                    .withProxyPort(PROXY_PORT)
                    .withProxyUsername(PROXY_USER)
                    .withProxyPassword(PROXY_PASSWORD))
                .build();
dagnir commented 6 years ago

Closing this due to no response. Please feel free to reopen if you're still experiencing issues.

DXTCODES commented 6 years ago

I was able to resolve that connectivity piece but I wanted to know how to enable encryption while creating the DynamoDB table.

dagnir commented 6 years ago

@DXTCODES are you asking about DynamoDB's Encryption At Rest feature? If you you should be able to find more information about it here: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/EncryptionAtRest.html

If you're looking for client-side encryption, you can find more information about that here: https://docs.aws.amazon.com/dynamodb-encryption-client/latest/devguide/what-is-ddb-encrypt.html

DXTCODES commented 6 years ago

I was trying to enable the encryption, while creating the Dynamo DB table from Java Application. My code for creating the table (with key ID) is below. Can you please help me in doing the encryption at in this code.

public static void createTable(AmazonDynamoDB client) { System.out.println("Creating table " + tableName); ArrayList attributeDefinitions = new ArrayList(); attributeDefinitions.add(new AttributeDefinition().withAttributeName( "Id").withAttributeType("N"));

    ArrayList<KeySchemaElement> ks = new ArrayList<KeySchemaElement>();
    ks.add(new KeySchemaElement().withAttributeName("Id").withKeyType(
            KeyType.HASH));

    ProvisionedThroughput provisionedThroughput = new ProvisionedThroughput()
            .withReadCapacityUnits(10L).withWriteCapacityUnits(10L);

    CreateTableRequest request = new CreateTableRequest()
            .withTableName(tableName)
            .withAttributeDefinitions(attributeDefinitions)
            .withKeySchema(ks)
            .withProvisionedThroughput(provisionedThroughput);

    CreateTableResult result = client.createTable(request);
    System.out.println(("Created table "
            + result.getTableDescription().getTableName()));
}