2013-05-15 48 views
0

我想使用「JetS3t」連接到Amazon S3存儲桶,我也使用Quartz插件, 我在grails-app/jobs中有一份工作,我喜歡在其中訪問S3 ,但我在socond線得到一個錯誤:Grails,使用jets3t連接到S3

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

S3Service s3Service = new RestS3Service(awsCredentials) 

這裏是錯誤:

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

我一定要創建服務,並設置我的S3嗎?

回答

0

這個工作對我來說:

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); 
    } 

當然,你不必把對象的多種方法,使用它們不過你想要的。

另外,還要確保你有這些進口:

import org.jets3t.service.impl.rest.httpclient.RestS3Service 
import org.jets3t.service.security.AWSCredentials