Initiating AmazonS3Client on GAE throws NoClassDefFoundError

I am trying to access the S3 bucket from the Google application engine, and I am getting an exception regarding a limited class trying to initialize the AmazonS3Client client. See code and exception below.

Any idea how to make this work?

the code:

AmazonS3 s3 = new AmazonS3Client(new ClasspathPropertiesFileCredentialsProvider()); 

An exception:

 Caused by: java.lang.NoClassDefFoundError: javax.management.MBeanServerFactory is a restricted class. Please see the Google App Engine developer 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) 
+7
google-app-engine amazon-s3 amazon-web-services
source share
1 answer

The error you encountered means that the class used by the AWS SDK is not allowed in App Engine (for some unclear reasons).

Even if you manage to get around this error, the AWS SDK cannot be run on GAE because it uses HttpClient and not URLFetch.

For more information you can read:

+2
source share

All Articles