ElasticBeanstalk Client

I am trying to develop an elastic beanstalk client interface for connecting through it to my elastic tape. I used my account credentials.Csl from the credentials.Csl script file. I signed up for my account with Google Chrome, but I am getting errors. Here is my code.

 package PFE; import com.amazonaws.AmazonClientException; import com.amazonaws.AmazonServiceException; import com.amazonaws.auth.AWSCredentials; import com.amazonaws.auth.profile.ProfileCredentialsProvider; import com.amazonaws.regions.Region; import com.amazonaws.regions.Regions; import com.amazonaws.services.elasticbeanstalk.AWSElasticBeanstalk; import com.amazonaws.services.elasticbeanstalk.AWSElasticBeanstalkClient; import com.amazonaws.services.elasticbeanstalk.model.CheckDNSAvailabilityResult; public class Sample { static AWSElasticBeanstalk eb; private static void init()throws Exception{ /* * The ProfileCredentialsProvider will return your [default] * credential profile by reading from the credentials file located at * (~/.aws/credentials). */ AWSCredentials credentials = null; try { credentials = new ProfileCredentialsProvider().getCredentials(); } catch (Exception e) { throw new AmazonClientException( "Cannot load the credentials from the credential profiles file. " + "Please make sure that your credentials file is at the correct " + "location (~/.aws/credentials), and is in valid format.", e); } eb = new AWSElasticBeanstalkClient(credentials); Region usWest2 = Region.getRegion(Regions.US_WEST_2); eb.setRegion(usWest2); } public static void main(String[] args) throws Exception { init(); try { CheckDNSAvailabilityResult c= eb.checkDNSAvailability(null); System.out.println("You have access to " + c.getAvailable() + " Availability Zones.") eb.createStorageLocation(); } catch (AmazonServiceException ase) { System.out.println("Caught Exception: " + ase.getMessage()); System.out.println("Reponse Status Code: " + ase.getStatusCode()); System.out.println("Error Code: " + ase.getErrorCode()); System.out.println("Request ID: " + ase.getRequestId()); } } } 

Here are the errors that I received when starting my project

  Exception in thread "main" java.lang.NoClassDefFoundError:org/apache/commons/logging/LogFactory at com.amazonaws.auth.profile.ProfilesConfigFile.<clinit>(ProfilesConfigFile.java:62) at com.amazonaws.auth.profile.ProfileCredentialsProvider.getCredentials(ProfileCredentialsProvider.java:106) at PFE.Sample.init(Sample.java:29) at PFE.Sample.main(Sample.java:47) Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory at java.net.URLClassLoader$1.run(URLClassLoader.java:202) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:248) 

I thought the problem was with the org.apache.commons.logging.LogFactory library, so I downloaded it and added it to my library links, but I still get the same errors.

+6
source share
3 answers

I got the same error trying to make an SQS sample ... My solution: do not add AWS SDK for Java, as to an external bank

Don't

But like a library.

enter image description here

+1
source

Instructions for NetBeans IDE :

  • Download the "SDK for Java" from this page

  • Extract all files from the archive, for example, to the / aws -java-sdk-1.9.22 folder

  • Copy the following files into the project:

    • /aws-java-sdk-1.9.22/lib/aws-java-sdk-1.9.22.jar

    • All * .jar files from the folder: /aws-java-sdk-1.9.22/third-party/

  • Now just add all * .jar files to your project in NetBeans IDE.

  • Profit!

+1
source

The problem was that there were other missing libraries, so I installed the AWS toolkit for my Eclipse Kepler with all the necessary libraries. http://aws.amazon.com/fr/eclipse/ ..link for download.

0
source

Source: https://habr.com/ru/post/972030/


All Articles