I'm trying to access an S3 bucket from Google app engine and I get an exception regarding a restricted class trying to initialize the AmazonS3Client client. See code and exception below.
Any idea how to make this work?
Code:
AmazonS3 s3 = new AmazonS3Client(new ClasspathPropertiesFileCredentialsProvider());
Exception:
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)
The error you encountered means that a class used by the AWS SDK is not allowed within App Engine (for some obscure reasons).
Even if you manage to bypass this error, the AWS SDK could not be run on GAE because it uses HttpClient and not URLFetch.
For more information you could read :
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With