5

I'm trying to learn the AWS SDK for Java. So, I set up an amazon account and went to this link

I downloaded the sample project, created my credentials file, and then tried to compile and run the sample.

The first time I did this, I received the error

[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] Source option 5 is no longer supported. Use 6 or later.
[ERROR] Target option 1.5 is no longer supported. Use 1.6 or later.

So I changed my pom.xml file from this:

<properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

to this:

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.6</maven.compiler.source>
    <maven.compiler.target>1.6</maven.compiler.target>
</properties>

The previous error went away, to be replaced by this new one:

[WARNING] 
java.lang.reflect.InvocationTargetException
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:564)
    at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:297)
    at java.lang.Thread.run (Thread.java:844)
Caused by: java.lang.NoClassDefFoundError: javax/xml/bind/DatatypeConverter
    at com.amazonaws.util.Base64.encodeAsString (Base64.java:36)
    at com.amazonaws.auth.AbstractAWSSigner.signAndBase64Encode (AbstractAWSSigner.java:70)
    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:3697)
    at com.amazonaws.services.s3.AmazonS3Client.createBucket (AmazonS3Client.java:788)
    at com.amazonaws.services.s3.AmazonS3Client.createBucket (AmazonS3Client.java:713)
    at com.amazonaws.samples.S3Sample.main (S3Sample.java:86)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:564)
    at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:297)
    at java.lang.Thread.run (Thread.java:844)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.DatatypeConverter
    at java.net.URLClassLoader.findClass (URLClassLoader.java:466)
    at java.lang.ClassLoader.loadClass (ClassLoader.java:566)
    at java.lang.ClassLoader.loadClass (ClassLoader.java:499)
    at com.amazonaws.util.Base64.encodeAsString (Base64.java:36)
    at com.amazonaws.auth.AbstractAWSSigner.signAndBase64Encode (AbstractAWSSigner.java:70)
    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:3697)
    at com.amazonaws.services.s3.AmazonS3Client.createBucket (AmazonS3Client.java:788)
    at com.amazonaws.services.s3.AmazonS3Client.createBucket (AmazonS3Client.java:713)
    at com.amazonaws.samples.S3Sample.main (S3Sample.java:86)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:564)
    at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:297)
    at java.lang.Thread.run (Thread.java:844)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.231 s
[INFO] Finished at: 2018-04-11T11:34:55-07:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:java (default-cli) on project aws-java-sample: An exception occured while executing the Java class. null: InvocationTargetException: javax/xml/bind/DatatypeConverter: javax.xml.bind.DatatypeConverter -> [Help 1]

I'm quite new to all of this and I've been googling around for a bit trying to find the answer with no luck. I'm sure the answer is incredibly obvious to people who know about this sort of thing. If you could simply point me in the right direction, I'd be really grateful.

GhostCat
  • 137,827
  • 25
  • 176
  • 248
Treecorn
  • 91
  • 1
  • 6
  • 4
    Hint: don't call yourself an idiot. Somebody is always listening, even when you are alone in the room. Don't take yourself down. Never helps with anything. You put up a well written question which people a bit more familiar with aws resp. maven setup should be able to answer. – GhostCat Apr 11 '18 at 18:39
  • 1
    I think this is not aws specific error rather than similar to [this](https://stackoverflow.com/questions/43574426/how-to-resolve-java-lang-noclassdeffounderror-javax-xml-bind-jaxbexception-in-j/43574427#43574427). Please try to add the mentioned dependencies from the __Proper long-term solution__ part. – Rashin Apr 11 '18 at 18:49
  • Can you write down the exact steps (commands) you went through? I checked out the repo on the link you provided and ran the mvn build and it all worked OK. Also which terminal are you using, git bash? – F_SO_K Apr 11 '18 at 20:19
  • Confirming what @stu said. mvn build and gradle build both built cleanly, didn't even get your original source and target option error. I suspect this has something to do with JDK version you're using. Try 8. – RaGe Apr 12 '18 at 03:06
  • This helped me with exactly the same problem: https://stackoverflow.com/a/46455026/4621324 – Axalix Jul 31 '18 at 19:36

0 Answers0