title: Why do I get java.lang.ClassNotFoundException: com.amazonaws.auth.AWSCredentials error?
body: <p>I have included the dependency from Maven, yet I see this error:</p>
  
  <p>java.lang.ClassNotFoundException: com.amazonaws.auth.AWSCredentials</p>
  
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;com.amazonaws&lt;/groupId&gt;
      &lt;artifactId&gt;aws-java-sdk&lt;/artifactId&gt;
      &lt;version&gt;1.8.5&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>Follwoing is the code that I am using and the method that I would like to call. It runs perfectly when called from a main method, but fails when called from a request.</p>
  
  <p>public class ThumbnailProcessor {</p>
  
  <pre><code>    public static String processThumbnail(String link, String keyName , String secret ) {
  
          AmazonS3 s3Client = null;
          link = StringUtils.removeEnd(link, "/");
          int index = link.lastIndexOf("/");
          String fileName = StringUtils.substring(link, index + 1, link.length());
          String existingBucketName = "staticmedia";
              String fileNameWithoutExt = StringUtils.substringBefore(fileName, ".");
          String ext = StringUtils.substringAfter(fileName, ".");
          InitiateMultipartUploadResult initResponse = null;
          String randomname = null;
          try {
              URL url = new URL(link);
              BufferedImage image = ImageIO.read(url);
              image = Thumbnails.of(image).forceSize(150, 100).asBufferedImage();
              randomname = String.format("%s.%s",
                      RandomStringUtils.randomAlphanumeric(8), ext);
              StringBuilder sb = new StringBuilder(randomname);
              sb.insert(0, fileNameWithoutExt + "_");
              randomname = sb.toString();
              ImageIO.write(image, "jpg", new File("src/main/java/" + randomname));
              String filePath = "src/main/java/" + randomname;
              AWSCredentials awsCredentials = new BasicAWSCredentials(keyName,
                      secret);
              s3Client = new AmazonS3Client(awsCredentials);
              InitiateMultipartUploadRequest initRequest = new InitiateMultipartUploadRequest(
                      existingBucketName, randomname);
              initResponse = s3Client.initiateMultipartUpload(initRequest);
              File file = new File(filePath);
  
              PutObjectResult item = s3Client.putObject(new PutObjectRequest(
                      existingBucketName, randomname, file));
              return "https://s3-us-west-2.amazonaws.com/"
                      + randomname;
          } catch (Exception e) {
              e.printStackTrace();
              s3Client.abortMultipartUpload(new AbortMultipartUploadRequest(
                      existingBucketName, randomname, initResponse.getUploadId()));
          }
          return null;
      }
  }
  </code></pre>