我正在尝试从Google应用引擎访问S3存储桶,并且我在尝试初始化AmazonS3Client客户端的受限类时遇到异常。请参阅下面的代码和例外。
知道如何使这项工作吗?
代码:
AmazonS3 s3 = new AmazonS3Client(new ClasspathPropertiesFileCredentialsProvider());
例外:
Caused by: java.lang.NoClassDefFoundError: javax.management.MBeanServerFactory is a restricted class. Please see the Google App Engine developer's guide for more details.
at com.google.appengine.tools.development.agent.runtime.Runtime.reject(Runtime.java:51)
at com.amazonaws.jmx.MBeans.getMBeanServer(MBeans.java:111)
at com.amazonaws.jmx.MBeans.registerMBean(MBeans.java:50)
at com.amazonaws.jmx.SdkMBeanRegistrySupport.registerMetricAdminMBean(SdkMBeanRegistrySupport.java:27)
at com.amazonaws.metrics.AwsSdkMetrics.registerMetricAdminMBean(AwsSdkMetrics.java:330)
at com.amazonaws.metrics.AwsSdkMetrics.<clinit>(AwsSdkMetrics.java:308)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:188)
at com.google.appengine.tools.development.agent.runtime.RuntimeHelper.checkRestricted(RuntimeHelper.java:70)
at com.google.appengine.tools.development.agent.runtime.Runtime.checkRestricted(Runtime.java:64)
at com.amazonaws.services.s3.AmazonS3Client.<clinit>(AmazonS3Client.java:231)
答案 0 :(得分:2)
您遇到的错误意味着AWS SDK中不允许使用AWS SDK(出于某些不明原因)。
即使您设法绕过此错误,AWS SDK也无法在GAE上运行,因为它使用的是HttpClient而不是URLFetch。
有关详细信息,请阅读: