Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Amazon S3 intgeration error: java.lang.NoClassDefFoundError: org/apache/http/protocol

    SmartClient Version: SC_SNAPSHOT-2012-01-05_v8.1p/Pro Deployment (built 2012-01-05)

    Firefox 6.0.2

    After attempting instantiating an implementation of Amazons S3 I get the following error at this line

    String errorString = client.putObject(bucketName, key, artFile);

    ERROR:
    java.lang.NoClassDefFoundError: org/apache/http/protocol/ImmutableHttpProcessor
    at org.apache.http.impl.client.AbstractHttpClient.getProtocolProcessor(AbstractHttpClient.java:728)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:879)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:826)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:804)
    at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:261

    ------------------------------------------------------------- S3 Class Implementation -------------------
    package com.packagename
    import com.amazonaws.auth.PropertiesCredentials;
    import com.amazonaws.services.s3.AmazonS3;
    import com.amazonaws.services.s3.AmazonS3Client;
    import com.amazonaws.services.s3.model.*;

    import java.io.File;
    import java.io.FileInputStream;
    import java.io.InputStream;
    import java.util.ArrayList;
    import java.util.List;


    public class S3 {
    private AmazonS3 s3;

    public S3(String credentials) throws Exception {

    s3 = new AmazonS3Client(new PropertiesCredentials(new FileInputStream(pace_credential_file_path)));

    }

    public void createBucket(String name) {
    s3.createBucket(name);
    }

    public void deleteBucket(String name) {
    s3.deleteBucket(name);
    }

    public List<String> getBucketNames() {
    List<Bucket> buckets = s3.listBuckets();
    List<String> names = new ArrayList<String>();
    for (Bucket bucket : buckets) names.add(bucket.getName());
    return names;
    }

    public String putObject(String bucketName, String key, File file) {
    PutObjectResult result = null;
    try{
    result = s3.putObject(new PutObjectRequest(bucketName, key, file));
    }catch(Exception e){
    System.err.println("\n\n ****************** AMAZON S3 PUTOBJECT FAILED \n\n");
    e.printStackTrace(System.err);

    }
    // PutObjectResult result = s3.putObject(bucketName, key, file);
    return result.getETag(); // returns the error tag
    }

    public void deleteObject(String bucketName, String key) {
    s3.deleteObject(bucketName, key);
    }

    public void upLoadFiles(String bucketName, String key, List<String> artFileNames){
    for(String artFileName: artFileNames) {
    File artFile = new File(artFileName);
    String error = putObject(bucketName, key, artFile);
    System.out.println("!!!!!!S3: Error - " + error);
    }
    }


    }

    ------------------------------------------------------Data Source where error occurs -------------------------

    public class ourDataSource extends BasicDataSource {

    @Override
    public DSResponse execute(DSRequest req) throws Exception {

    try{
    S3 client = new S3(credentialFile);
    ERROR ---> String errorString = client.putObject(bucketName, key, artFile);
    }catch(Exception e){
    System.err.println("\n\n ****************** DID NOT RUN AMAZON S3 TEST - did you set up credentials?\n\n");
    e.printStackTrace(System.err);
    }
    }
    }

    Posts with incomplete information are much more likely to be ignored.
    Last edited by Mitch B; 26 Jan 2012, 18:30.

    #2
    Apache Core 4.0.1 does not contain the ImmutableHttpProcessor but 4.1.3 does and this is used by S3.

    Comment

    Working...
    X