NoClassDefFoundError when trying to execute SQS login even though the class is in the same jar as calling class

60 views
Skip to first unread message

Benjamin Liu via StackOverflow

unread,
Jun 8, 2016, 3:15:09 PM6/8/16
to google-appengin...@googlegroups.com

I'm running tasks using the Google App Engine task queue. I can run everything locally (i.e. login and put stuff on a queue); however, when I run the task on an app-engine instance, it will fail with a NoClassDefFoundError like so:

java.lang.NoClassDefFoundError: Could not initialize class com.amazonaws.ClientConfiguration
at com.amazonaws.ClientConfigurationFactory.getDefaultConfig(ClientConfigurationFactory.java:46)
at com.amazonaws.ClientConfigurationFactory.getConfig(ClientConfigurationFactory.java:35)
at com.amazonaws.services.sqs.AmazonSQSClient.<init>(AmazonSQSClient.java:212)

However, this is really strange since the ClientConfigurationFactory class is in the aws-java-sdk-core jar as well as the ClientConfiguration class, so it's strange that it finds one but not the other.

I see both of these jars in my classpath when I run the deploy:

/home/ubuntu/.m2/repository/com/amazonaws/aws-java-sdk-sqs/1.11.7/aws-java-sdk-sqs-1.11.7.jar,

/home/ubuntu/.m2/repository/com/amazonaws/aws-java-sdk-core/1.11.7/aws-java-sdk-core-1.11.7.jar,

And I am running this operation:

mvn -DskipTests=true -X --activate-profiles $LOCATION -DCIRCLE_BUILD_NUM=${CIRCLE_BUILD_NUM} appengine:update

Here's the code that actually performs the login request:

    AWSCredentials credentials = new ClasspathPropertiesFileCredentialsProvider().getCredentials();
    AmazonSQS sqs = new AmazonSQSClient(credentials);
    Region usWest1 = Region.getRegion(Regions.US_WEST_1);
    sqs.setRegion(usWest1);
    return sqs;

Anybody have any ideas? Need more context?

Thanks in advance



Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/37710968/noclassdeffounderror-when-trying-to-execute-sqs-login-even-though-the-class-is-i

Nick via StackOverflow

unread,
Jun 9, 2016, 6:20:16 PM6/9/16
to google-appengin...@googlegroups.com

ClassDefNotFound is being thrown because the class can not be initialised, not because it isn't on your class path.

This happens when a static initialisation block throws an exception.

If you have the source, look for any static init blocks or classes (such as factories) which are instantiated inline. One of these is throwing an exception.

You can also try debugging to catch and see the root cause in the exception, which should give you the underlying exception.



Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/37710968/noclassdeffounderror-when-trying-to-execute-sqs-login-even-though-the-class-is-i/37737095#37737095
Reply all
Reply to author
Forward
0 new messages