运行Grails AWS插件时出现ClassNotFoundException

时间:2014-02-14 23:31:04

标签: grails amazon-web-services amazon-s3

我在Grails 2.2.2上使用Grails AWS插件:https://github.com/grails-aws/grails-aws。我无法让基本的S3文件上传工作。我收到以下错误:

错误日志:

ERROR (SLF4JBridgeHandler.java:225) - Servlet.service() for servlet [default] in context with path [] threw exception [org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.NoClassDefFoundError: org/apache/http/params/SyncBasicHttpParams] with root cause
java.lang.ClassNotFoundException: org.apache.http.params.SyncBasicHttpParams
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    at org.jets3t.service.utils.RestUtils.createDefaultHttpParams(RestUtils.java:574)
    at org.jets3t.service.utils.RestUtils.initHttpConnection(RestUtils.java:298)
    at org.jets3t.service.impl.rest.httpclient.RestStorageService.initHttpConnection(RestStorageService.java:209)
    at org.jets3t.service.impl.rest.httpclient.RestStorageService.initializeDefaults(RestStorageService.java:166)
    at org.jets3t.service.StorageService.<init>(StorageService.java:125)
    at org.jets3t.service.impl.rest.httpclient.RestStorageService.<init>(RestStorageService.java:153)
    at org.jets3t.service.S3Service.<init>(S3Service.java:91)
    at org.jets3t.service.impl.rest.httpclient.RestS3Service.<init>(RestS3Service.java:157)
    at org.jets3t.service.impl.rest.httpclient.RestS3Service.<init>(RestS3Service.java:131)
    at org.jets3t.service.impl.rest.httpclient.RestS3Service.<init>(RestS3Service.java:109)
    at grails.plugin.aws.s3.S3FileUpload.inputStreamUpload(S3FileUpload.groovy:85)
    at grails.plugin.aws.util.MetaClassInjector$_injectS3UploadMethods_closure3.doCall(MetaClassInjector.groovy:46)

这是BuildConfig:

compile ":aws:1.6.7.5"

控制器:

file.inputStream.s3upload(newFilename) {
   path "pictures/"
}

所以这里没什么特别的,只是基本配置,但它不起作用。有什么想法吗?

UDPATE:

使用依赖关系报告以确保应用程序正在使用HTTPClient 4.2,它是:

httpclient by org.apache.httpcomponents 4.2 4.1.2

由于

2 个答案:

答案 0 :(得分:2)

Grails AWS插件使用AWS SDK 1.6.7,它依赖于Apache HttpClient 4.2,您可以从Maven了解。

请将以下依赖项添加到BuildConfig.groovy

runtime 'org.apache.httpcomponents:httpclient:4.2'

答案 1 :(得分:1)

我终于可以通过将以下内容添加到 BuildConfig.groovy 来使其工作:

build 'org.apache.httpcomponents:httpcore:4.2'
build 'org.apache.httpcomponents:httpclient:4.2'
runtime 'org.apache.httpcomponents:httpcore:4.2'
runtime 'org.apache.httpcomponents:httpclient:4.2'