aws-samples / aws-java-sample

Sample project to demonstrate usage of the AWS SDK for Java
Apache License 2.0
231 stars 339 forks source link

AmazonClientException #7

Open timbog opened 9 years ago

timbog commented 9 years ago

I've got some troubles with running this sample. I've followed instructions on http://aws.amazon.com/ru/developers/getting-started/java/, and after running mvn clean compile exec:java I've got AmazonClientException(Unable to execute HTTP request: peer not authenticated) followed by "Unable to execute HTTP request: peer not authenticated". This things happen when I am trying to create bucket, so I've got "Creating bucket my-first-s3-bucket-865cc23b-7f73-4e09-a9d9-c38382d72e2b" and then an error. I've looked throw https://forums.aws.amazon.com/message.jspa?messageID=429971, but unfortunately I don't completely understand how to use suggested solution (http://javaskeleton.blogspot.ie/2010/07/avoiding-peer-not-authenticated-with.html) here.

ghost commented 9 years ago

Hi @timbog,

There are many things that could be causing the "peer not authenticated" error. Can you try adding -Djavax.net.debug=ssl when running the app to see what might be happening?

fulghum commented 9 years ago

What JVM version are you running? It sounds like you might be using an older version without up to date CA certs in your keystore.

kiran1920 commented 9 years ago

I am getting the following error while running Could you please help on this

Creating bucket my-first-s3-bucket-3c2698bd-a429-4b9d-ae73-046fcbed0e66

com.amazonaws.AmazonClientException: Unable to calculate a request signature: null at com.amazonaws.auth.AbstractAWSSigner.signAndBase64Encode(AbstractAWSSigner.java:71) at com.amazonaws.auth.AbstractAWSSigner.signAndBase64Encode(AbstractAWSSigner.java:58) at com.amazonaws.services.s3.internal.S3Signer.sign(S3Signer.java:127) at com.amazonaws.http.AmazonHttpClient.executeOneRequest(AmazonHttpClient.java:652) at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:460) at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:295) at com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:3699) at com.amazonaws.services.s3.AmazonS3Client.createBucket(AmazonS3Client.java:788) at com.amazonaws.services.s3.AmazonS3Client.createBucket(AmazonS3Client.java:713) at main.java.com.amazonaws.samples.S3Sample.main(S3Sample.java:100) Caused by: java.lang.NullPointerException at javax.xml.bind.DatatypeConverter.printBase64Binary(Unknown Source) at com.amazonaws.util.Base64.encodeAsString(Base64.java:36) at com.amazonaws.auth.AbstractAWSSigner.signAndBase64Encode(AbstractAWSSigner.java:69) ... 9 more Caught an AmazonClientException, which means the client encountered a serious internal problem while trying to communicate with S3, such as not being able to access the network. Error Message: Unable to calculate a request signature: null

fulghum commented 9 years ago

Hey @kiran1920, it sounds like you might need to double-check your AWS security credentials and make sure this sample code is picking them up correctly.

Have you created the .aws/credentials file in your home directory? It should look something like this:

[default]
aws_access_key_id = YOUR_ACCESS_KEY_ID
aws_secret_access_key = YOUR_SECRET_ACCESS_KEY
lcfarrington commented 9 years ago

I am trying to run this and am getting the following error Caught an AmazonServiceException, which means your request made it to Amazon S3, but was rejected with an error response for some reason. Error Message: Access Denied (Service: Amazon S3; Status Code: 403; Error Code: AccessDenied; Request ID: 3FC6FAECDE3A19A1). I checked my access keys and believe that they are correct. How can I go about researching this further?

lcfarrington commented 9 years ago

Answering my own question. My permissions were not correct. I needed to give full access to S3.

SharathDharmala commented 4 years ago

While iam trying to create a bucket, below exception i got..

Caught an AmazonClientException, which means the client encountered a serious internal problem while trying to communicate with S3, such as not being able to access the network.

Error Message: Unable to execute HTTP request:....