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
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.