aws-sdk-java: Java SDK issues on EMR cluster : java.lang.IllegalAccessError: tried to access class
java.lang.IllegalAccessError: tried to access class
com.amazonaws.services.s3.AmazonS3ClientConfigurationFactory from class
com.amazonaws.services.s3.AmazonS3Builder at com.amazonaws.services.s3.AmazonS3Builder.<clinit>(AmazonS3Builder.java:30)
when trying to use
s3Client = AmazonS3ClientBuilder.standard().withCredentials(new
AWSStaticCredentialsProvider(credentials)).build()
with the jars bellow at the class-path.
aws-java-sdk-1.11.111.jar,\
aws-java-sdk-core-1.11.111.jar,\
aws-java-sdk-s3-1.11.111.jar,\
aws-java-sdk-kinesis-1.11.111.jar
EMR 5.4, on AWS, and this is a scala 2.11 - mvn project (Apache Maven 3.3.9)
Is there any way to use the new, and not the deprecated SDK on the EMR cluster?
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Reactions: 7
- Comments: 17 (5 by maintainers)
I tried to get
classOf[AmazonS3ClientBuilder].getProtectionDomain().getCodeSource().getLocation()but it threwjava.lang.IllegalAccessError. My understanding is that spark-submit ignores the jars submitted by the user and uses the jars under/usr/share/aws/aws-java-sdk/which forEMR 5.4are of version1.10.75.1.spark-submithas a parameter which can override the server jars with the user jars, however this can cause other issues. All the paths are configured here :/etc/spark/conf/spark-defaults.conf.Possible solutions to the issue I found [I think they are all irrelevant to this repository, and more relevant to the
EMRcluster setup and the wayspark-submitworks]:/etc/spark/conf/spark-defaults.confthat either adds the new jars path or removed the old one (you can do this in the bootstrap phase)This should disable the old jars in bootstrap:
sed -i.bak "s|:/usr/share/aws/aws-java-sdk/*||g" /etc/spark/conf/spark-defaults.conf(I have not tested it yet)I am facing the same issue , did you find any fix ?
I’m also experiencing this same error. Downgrading to 1.10.77 also fixed my issue.
I did have to switch
AmazonS3ClientBuilder.defaultClient()with the currently deprecatednew AmazonS3Client()to get things working@EXPEgdube thanks for the update, that’s good to know.
I got my app working using the deprecated
com.amazonaws.services.s3.AmazonS3Clientclass on EMR.Agreed, it seems the Spark dependencies provided by EMR are the issue. The application will run fine locally or on an EC2 when I provide the Spark 2.1.0 jars.
I have forwarded this feedback to the EMR service team.