Question

I am trying to connect to Amazon S3 Buckets using "JetS3t", I am also using Quartz plugin, I have a job in grails-app/jobs, in which I like to access S3, but I get an error in the socond line:

AWSCredentials awsCredentials = new AWSCredentials(grailsApplication.config.s3.accessKey, grailsApplication.config.s3.secretKey)

S3Service s3Service = new RestS3Service(awsCredentials)

here is the error:

ERROR listeners.ExceptionPrinterJobListener  - Exception occurred in job: null
Message: java.lang.NoClassDefFoundError: com/jamesmurty/utils/XMLBuilder

Do I have to create a service and set up my S3 there?

Was it helpful?

Solution

This works for me:

def aws_credentials = {
        return new AWSCredentials(grailsApplication.config.aws.accessKey, grailsApplication.config.aws.secretKey)
    }

    def s3_service = {
        return new RestS3Service(aws_credentials())
    }

    def test = {
        def buckets = s3_service().listAllBuckets()
        System.out.println("How many buckets to I have in S3? " + myBuckets.length);
    }

And of course you don't have to put the objects in multiple methods, use them however you want.

Also make sure you have these imports:

import org.jets3t.service.impl.rest.httpclient.RestS3Service
import org.jets3t.service.security.AWSCredentials
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top