Could not initialize class com.amazonaws.services.sqs.AmazonSQSClient

Question:

First of all Im new to JAVA AWS Eclipse Maven Tomcat… Im getting the following error while trying following code.. Error is “HTTP Status 500 – java.lang.NoClassDefFoundError: Could not initialize class com.amazonaws.services.sqs.AmazonSQSClient”…

}

pom.xml

Answer:

java.lang.NoClassDefFoundError simply means:

“Hey dude, when you (automatically) built your project in Eclipse
(and/or in Maven) (compilation time), your IDE was able to find this class
com.amazonaws.services.sqs.AmazonSQSClient. But when you want to run on
the server (runtime) , I can’t find it any-more.”

so you are missing a class at runtime which was compiled before.

Now please do this:

A- Cleaning phase

  1. in eclipse go to Menubar -> clean -> clean all project.
  2. if eclipse doesn’t support maven yet (e.g not having m2e): open your command line (Windows or Linux or whatever) and move to the directory which contains you eclipse project and type “mvn clean”.
  3. if eclipse does support m2e then, directly in eclipse on your project right-click -> maven -> update project.

B- Configuration Phase:

  1. in your eclipse project, right-click -> Deployment Assembly. You’ll see a kind of table with columns “source” and “Deploy Path”. if there no row with source “Maven Dependency”, please make sure your one by click the button add -> Java Build path Entries -> next button -> “Maven Dependency”.
  2. Once the “Maven Dependency” has been added, please make sure its deploy Path value is “WEB-INF/lib”.

C- Deploy and Runtime

  1. right-click on your project -> maven install
  2. right-click on your project -> run as (or debug as) -> select you tomcat and than start it. your project must be have been configured by then.

make sure you have installed the eclipse plugin m2e. It ‘ll make your development life in eclipse/maven easier.

Leave a Reply