java.lang.illegalaccesserror:无法访问其上级接口

l2osamch  于 2021-06-04  发布在  Hadoop
关注(0)|答案(1)|浏览(512)

问题:我有两个具有相同限定路径的java类。
我正在运行一个emr作业,为此,我将所有依赖jar打包在一个jar中,并上传到s3。emr集群应该从s3中使用这个jar。但我得到了一个错误:

Exception in thread "main" java.lang.IllegalAccessError: class org.apache.hadoop.fs.s3native.AbstractNativeS3FileSystemStore cannot access its superinterface org.apache.hadoop.fs.s3native.NativeFileSystemStore at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:800) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:449) at java.net.URLClassLoader.access$100(URLClassLoader.java:71) at java.net.URLClassLoader$1.run(URLClassLoader.java:361) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:425) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:270) at org.apache.hadoop.conf.Configuration.getClassByName(Configuration.java:861) at org.apache.hadoop.conf.Configuration.getClass(Configuration.java:906) at org.apache.hadoop.fs.FileSystem.createFileSystem(FileSystem.java:1411) at org.apache.hadoop.fs.FileSystem.access$200(FileSystem.java:68) at org.apache.hadoop.fs.FileSystem$Cache.get(FileSystem.java:1435) at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:260) at org.apache.hadoop.fs.Path.getFileSystem(Path.java:187) at org.apache.hadoop.mapreduce.lib.input.FileInputFormat.setInputPaths(FileInputFormat.java:352) at org.apache.hadoop.mapreduce.lib.input.DelegatingInputFormat.getSplits(DelegatingInputFormat.java:110) at org.apache.hadoop.mapred.JobClient.writeNewSplits(JobClient.java:1016) at org.apache.hadoop.mapred.JobClient.writeSplits(JobClient.java:1033) at org.apache.hadoop.mapred.JobClient.access$700(JobClient.java:174) at org.apache.hadoop.mapred.JobClient$2.run(JobClient.java:951) at org.apache.hadoop.mapred.JobClient$2.run(JobClient.java:904) at java.security.AccessController.doPrivileged(Native Method) at javax.security.auth.Subject.doAs(Subject.java:415) at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1140) at org.apache.hadoop.mapred.JobClient.submitJobInternal(JobClient.java:904) at org.apache.hadoop.mapreduce.Job.submit(Job.java:501) at org.apache.hadoop.mapreduce.Job.waitForCompletion(Job.java:531) at com.amazon.idq.chia.aws.emr.mains.BaseFilterStepMain.configureAndRunJob(BaseFilterStepMain.java:51) at com.amazon.idq.chia.aws.emr.mains.BaseFilterStepMain.run(BaseFilterStepMain.java:84) at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:65) at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:79) at com.amazon.idq.chia.aws.emr.mains.FFilterHybridStepMain.main(FFilterHybridStepMain.java:24) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.apache.hadoop.util.RunJar.main(RunJar.java:187)

我一直在尝试的是:我注意到两个版本的可见性是不同的。我以为类加载器从jar1中提取nativefilesystemstore(默认访问)类,而代码期望的是nativefilesystemstore(公共访问)类的jar2版本。所以,我修改了构建脚本:1。打开jar1和jar2的拉链。2从jar1中删除了限制类nativefilesystemstore。三。将org.apache.hadoop.fs.s3native.*从jar2移动到jar13。将类重新打包为jar1-resolved.jar和jar2-resolved.jar4。再次尝试运行emr作业。
结果:仍然得到相同的错误。

xnifntxz

xnifntxz1#

在大多数情况下,illegalaccesserror的原因是版本不匹配。请在org.apache.hadoop.fs.s3native.nativefilesystemstore(您在解析的jar中包含的文件)和org.apache.hadoop.fs.s3native.abstractnatives3filesystemstore(我相信您已经编写了代码)文件上运行“javap-version”或“javap-verbose$classname$| grep'major'”,并检查它们是否匹配。

相关问题