DorkRawk
DorkRawk

Reputation: 770

java.lang.NoClassDefFoundError on new AmazonS3Client

When I try to create a new AmazonS3Client object

client = new AmazonS3Client(new BasicAWSCredentials(S3ACCESS_KEY, S3SECRET_KEY));

I get this error:

Caused by: java.lang.NoClassDefFoundError: org/apache/http/HttpRequest

My project has the httpcore-4.1.jar included and I can see the HttpRequest.class file in there. I also have the httpclient-4.1.3.jar included. Would that have any affect on this?

The project builds just fine and I only run into this error when I create a new AmazonS3Client object. Any ideas?

Upvotes: 2

Views: 4186

Answers (2)

DorkRawk
DorkRawk

Reputation: 770

After a lot of banging my head against the wall I ended up just re-cloning the repo and it worked fine. I must have just screwed up my config in the version I was working on. Not very satisfying, but it works fine now.

Upvotes: -1

Nikola Yovchev
Nikola Yovchev

Reputation: 10266

I believe your problem is a wrong version of http client. Looking at amazonws maven artifact, it is depending on`HttpCLient 4.2.1.

<dependency>
    <groupId>com.amazonaws</groupId>
    <artifactId>aws-java-sdk</artifactId>
    <version>1.2.15</version>
</dependency>

Uses HttpClient 4.2.1.

Upvotes: 2

Related Questions