2014-07-10 3 views
6

Ich versuche, ein elastisches beanstalk client Interface zu entwickeln, um sich durch es mit meinem Amazonas-Konto elasticbeanstalk zu verbinden. Ich habe die Anmeldeinformationen meines Kontos in der Skriptdatei credentials.Csl verwendet. Ich habe mich über Google Chrome bei meinem Konto angemeldet, erhalte jedoch Fehler. Hier ist mein Code.ElasticBeanstalk Client

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()); 
    }     
} 

} 

Hier sind die Fehler, die ich bekam, als mein Projekt

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) 

ich das Problem, dachte läuft mit der org.apache.commons.logging.LogFactory Bibliothek so heruntergeladen ich es und es zu meiner referenzierten Bibliotheken, aber ich Ich bekomme immer noch die gleichen Fehler.

Antwort

1

bekam ich den gleichen Fehler beim Versuch, eine SQS Probe zu machen ... Meine Lösung ist: Sie AWS SDK nicht als externe jar

Don't

Aber als Bibliothek für Java hinzuzufügen.

enter image description here

0

Das Problem war, dass es andere fehlende Bibliotheken, so installiert i das Toolkit AWS für meine Eclipse-Kepler, mit allen notwendigen Bibliotheken. http://aws.amazon.com/fr/eclipse/ ..link zum Download.

1

Anleitung für NetBeans IDE:

  1. Download "SDK für Java" von this Seite

  2. Extrahieren Sie alle Dateien aus dem Archiv zum Beispiel in Ordner /aws-java-sdk-1.9. 22

  3. Kopieren nächste Dateien zu einem Projekt:

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

    • Alle * .jar-Dateien aus dem Ordner: /aws-java-sdk-1.9.22/Fremd/

  4. Nun fügen Sie einfach alle mit * .jar-Dateien zu einem Projekt in NetBeans IDE.

  5. Gewinn!

Verwandte Themen