-1
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/protocol/HttpContext
 at com.amazonaws.AmazonWebServiceClient.<init>(AmazonWebServiceClient.java:119)
 at com.amazonaws.AmazonWebServiceClient.<init>(AmazonWebServiceClient.java:103)
 at com.amazonaws.services.s3.AmazonS3Client.<init>(AmazonS3Client.java:362)
 at com.amazonaws.services.s3.AmazonS3Client.<init>(AmazonS3Client.java:344)
 at Gethtml_fromS3.main(Gethtml_fromS3.java:16)
Caused by: java.lang.ClassNotFoundException: org.apache.http.protocol.HttpContext
 at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
 at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
 at java.security.AccessController.doPrivileged(Native Method)
 at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
 at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
 ... 5 more

Can any one give me a solution for the above error?

chiastic-security
  • 20,430
  • 4
  • 39
  • 67
Rafi
  • 81
  • 2
  • 10
  • 1
    http://stackoverflow.com/search?q=NoClassDefFoundError – Matt Ball Sep 21 '14 at 18:53
  • possible duplicate of [Why am I getting a NoClassDefFoundError in Java?](http://stackoverflow.com/questions/34413/why-am-i-getting-a-noclassdeffounderror-in-java) – pamps Sep 21 '14 at 18:55

2 Answers2

3

Please check if you have httpcore jar. I got rid of this error, after adding httpcore-4.2.jar to my lib.

2

It's difficult to pinpoint the exact reason why your application raises this exception, but a few common pointers that might help you.

The exception is raised when you are using a class in your code that isn't available when it runs. In this case, it seems you are unable to use org.apache.http.protocol.HttpContext. Most likely, you created an application that does include the Amazon AWS jar, but lacks the Apache HTTPClient jar.

If you used gradle/maven to create your application, include it in your dependencies. It it's a plain Java program, ensure the required JARs are available in your classpath (e.g. the same place as you currently have the Amazon jar located).

Seshoumaro
  • 86
  • 2