7

Using Eclipse Mars .I have already added aws java sdk 1.11.123 through install software from help.Now when i run Tomcat Server 7 I get this error:

May 02, 2017 11:57:32 PM org.apache.catalina.core.StandardWrapperValve invoke SEVERE: Servlet.service() for servlet [PdsServlet] in context with path [/PdsAWS] threw exception [java.lang.NoClassDefFoundError: Could not initialize class com.amazonaws.partitions.PartitionsLoader] with root cause java.lang.NoClassDefFoundError: Could not initialize class com.amazonaws.partitions.PartitionsLoader

I also get

java.lang.NoSuchFieldError: ALLOW_FINAL_FIELDS_AS_MUTATORS

But when i check library i can see PartitionsLoader.How can this be resolved?

enter image description here

More errors which seem related:

May 03, 2017 9:39:04 AM com.sun.jersey.spi.container.ContainerResponse mapMappableContainerException
SEVERE: The exception contained within MappableContainerException could not be mapped to a response, re-throwing to the HTTP container
java.lang.NoClassDefFoundError: Could not initialize class com.amazonaws.partitions.PartitionsLoader
    at com.amazonaws.regions.RegionMetadataFactory.create(RegionMetadataFactory.java:30)
    at com.amazonaws.regions.RegionUtils.initialize(RegionUtils.java:64)
    at com.amazonaws.regions.RegionUtils.getRegionMetadata(RegionUtils.java:52)
    at com.amazonaws.regions.RegionUtils.getRegion(RegionUtils.java:105)
    at com.amazonaws.services.s3.AmazonS3Client.createSigner(AmazonS3Client.java:3428)
    at com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:4156)
    at com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:4116)
    at com.amazonaws.services.s3.AmazonS3Client.putObject(AmazonS3Client.java:1700)
    at com.amazonaws.services.s3.AmazonS3Client.putObject(AmazonS3Client.java:1563)
    at com.tradingtechnologies.pdsawssql.aws.s3.S3HealthCheck.put(S3HealthCheck.java:83)
    at com.tradingtechnologies.pdsawssql.aws.s3.S3HealthCheck.put(S3HealthCheck.java:56)
    at com.tradingtechnologies.pdsawssql.aws.s3.S3HealthCheck.execute(S3HealthCheck.java:116)
    at com.tradingtechnologies.pdsawssql.sql.ext.HealthCheck.execute(HealthCheck.java:54)
    at com.tradingtechnologies.pdsservlet.HealthServlet.doGet(HealthServlet.java:31)
    at sun.reflect.GeneratedMethodAccessor35.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)
    at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:205)
    at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
    at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:302)
    at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
    at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
    at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
    at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1511)
    at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1442)
    at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1391)
    at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1381)
    at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:416)
    at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:538)
    at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:716)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at com.tradingtechnologies.pdsservercommon.filters.HttpHeaderFilter.doFilter(HttpHeaderFilter.java:24)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:218)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:110)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:506)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:962)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:445)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1115)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:745)
General Grievance
  • 4,555
  • 31
  • 31
  • 45
vks
  • 67,027
  • 10
  • 91
  • 124

4 Answers4

6

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?

David Murray
  • 4,475
  • 1
  • 14
  • 16
  • my aws_java_sdk has jackson version 2.6.6 and there is a jackson version 2.1.2 in library outside aws_java_sdk.....can this be the issue? how can i make sure aws_java_sdk pickes the internal one – vks May 03 '17 at 14:24
  • Thanx a lot........this was it!!!!!!!!!!!!Compile time and runtime was differernt – vks May 03 '17 at 16:43
  • Hi there, excatly the same problem. Could you please tell me how you fixed it? I can see the problem but can't find a solution. Thanks in advance! – ldepablo Oct 27 '17 at 09:34
1

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.

MiiinimalLogic
  • 820
  • 6
  • 11
  • Which version of tomcat are you running ? And what is the contents of the 'WEB-INF/lib' folder in your project? – MiiinimalLogic May 03 '17 at 11:49
  • there is nothing in lib folder...there is no lib folder in fact!!!!!!!! – vks May 03 '17 at 12:32
  • I just edited my answer. I have a feeling you or the person before you created the project as a regular java project which would explain why you don't have that lib folder :) – MiiinimalLogic May 03 '17 at 12:45
  • I just import the project and the build and run it.....run on server...will try what u suggested – vks May 03 '17 at 12:49
  • didn't exactly do it...but the issue was different Jackson version at runtime Vs compile time – vks May 04 '17 at 12:52
  • Ha go figure, I remember battling w dependencies on build vs run w tomcat, hence my answer. Good luck. – MiiinimalLogic May 04 '17 at 13:05
  • yes dat is why I upvoted urs....but the other answer was more concise....so I market it...it's done. Now....check d. Other answer – vks May 04 '17 at 13:06
  • Thx for the upvote maybe it'll help another..other answer is on point. – MiiinimalLogic May 04 '17 at 13:08
1

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)
Nrj
  • 6,723
  • 7
  • 46
  • 58
0

I had same probler in past In my case I'm set pom.xml like above and solve problem

  1. set aws-java-sdk-bom

     <repositories>
     <repository>
         <id>mvn2</id>
         <url>http://repo1.maven.org/maven2/</url>
         <releases>
             <enabled>true</enabled>
         </releases>
         <snapshots>
             <enabled>true</enabled>
         </snapshots>
     </repository>
     <repository>
         <id>egovframe</id>
         <url>http://www.egovframe.go.kr/maven/</url>
         <releases>
             <enabled>true</enabled>
         </releases>
         <snapshots>
             <enabled>false</enabled>
         </snapshots>
     </repository>
     <repository>
         <id>egovframe2</id>
         <url>http://maven.egovframe.kr:8080/maven/</url>
         <releases>
             <enabled>true</enabled>
         </releases>
         <snapshots>
             <enabled>false</enabled>
         </snapshots>
     </repository>
    

must set isolate dependencyManagement field and be first field

**<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>com.amazonaws</groupId>
      <artifactId>aws-java-sdk-bom</artifactId>
      <version>1.11.837</version>
    </dependency>
</dependencies>
</dependencyManagement>**
<dependencies>
    <dependency>
        <groupId>egovframework.rte</groupId>
        <artifactId>egovframework.rte.ptl.mvc</artifactId>
        <version>${egovframework.rte.version}</version>
        <exclusions>
  1. aws-sdk-s3, core, kms

and set s3, core, kms config in field

<dependencies>
    <dependency>
        <groupId>egovframework.rte</groupId>
        <artifactId>egovframework.rte.ptl.mvc</artifactId>
        <version>${egovframework.rte.version}</version>
        <exclusions>
            <exclusion>

.......

<dependency>
        <groupId>commons-fileupload</groupId>
        <artifactId>commons-fileupload</artifactId>
        <version>1.2.1</version>
    </dependency>
    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-io</artifactId>
        <version>1.3.2</version>
    </dependency>

    **<dependency>
        <groupId>com.amazonaws</groupId>
        <artifactId>aws-java-sdk-core</artifactId>
        <version>1.11.837</version>
    </dependency>
    <dependency>
        <groupId>com.amazonaws</groupId>
        <artifactId>aws-java-sdk-s3</artifactId>
        <version>1.11.837</version>
    </dependency>
    <dependency>
        <groupId>com.amazonaws</groupId>
        <artifactId>aws-java-sdk-kms</artifactId>
            <version>1.11.837</version>
    </dependency>**
</dependencies>