Could not initialize class com.amazonaws.partitions.PartitionsLoader

∥☆過路亽.° 提交于 2019-12-01 03:58:54

java.lang.NoSuchFieldError: ALLOW_FINAL_FIELDS_AS_MUTATORS

This makes it sound like you're picking up an old version of Jackson from somewhere. PartitionsLoader references MapperFeature.ALLOW_FINAL_FIELDS_AS_MUTATORS while initializing a static member field. If the version of MapperFeature that you pick up at runtime does not have this field, the resulting exception will cause the class initialization process for PartitionsLoader to fail. Subsequent attempts to reference the class will then throw the exception you're seeing.

ALLOW_FINAL_FIELDS_AS_MUTATORS was added in version 2.2. Which version are you picking up?

Tomcat has its own file for dependencies. It is possible to configure the build path in Eclipse AND not add the dependencies to Tomcat for the build/deploy which could cause Java to throw that error.

Recreate your project as a dynamic web project in Eclipse (Check the documentation on how to do that if you're not familiar). Then include any 3rd party jars or libs in the auto-generated 'WEB-INF/lib' folder in addition to the build path necessary to run from source in Eclipse (aka the way you're doing it now). Then when you're ready to deploy, export to a war file and all the necessary libs in the 'WEB-INF/lib' folder will be visible to your compiled source.

Ok, I have faced the same dependency hell challenge and took long time to cleanup. Below are my set of dependencies which need to be made in sync -

  • Rule of thumb : Always use same aws sdk dependency version (core/s3/ec2 etc)
  • Make other dependency (used by aws) consistent across your project.
  • This included the following for me
    • commons-http clash with http-client used by AWS
    • Remove commons-http, use consistent http-client and http-core version
    • clashing fasterxml.jackson libraries. Use consistent verison used by aws.
      • This includes about 4 jars (jackson-databind, core, annotations, cbor)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!