2014-07-10 9 views
6

मैं अपने अमेज़ॅन खाते elasticbeanstalk से कनेक्ट करने के लिए एक लोचदार बीनस्टॉक क्लाइंट इंटरफ़ेस विकसित करने का प्रयास करता हूं। मैंने स्क्रिप्ट फ़ाइल credentials.Csl से अपने खाते के प्रमाण-पत्रों का उपयोग किया। मैंने Google क्रोम से अपने खाते में साइन अप किया लेकिन मुझे त्रुटियां मिल रही हैं। मेरा कोड यहाँ है।लोचदार बीनस्टॉक क्लाइंट

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

} 

यहाँ त्रुटियों कि मुझे मिल गया जब मेरी परियोजना चल

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) 

मैंने सोचा था कि समस्या यह है के साथ org.apache.commons.logging.LogFactory पुस्तकालय तो मैं इसे डाउनलोड किया है और मेरे संदर्भित पुस्तकालयों में जोड़ा हैं, लेकिन मैं मुझे अभी भी वही त्रुटियां मिल रही हैं। के रूप में एक बाहरी जार

Don't

के रूप में लेकिन एक पुस्तकालय के रूप में जावा के लिए एडब्ल्यूएस एसडीके न जोड़ें:

उत्तर

1

मैं एक ही त्रुटि एक SQS नमूना बनाने का प्रयास करते समय मिल गया ... मेरी समाधान है।

enter image description here

0

समस्या अन्य लापता पुस्तकालयों देखते हैं कि था, इसलिए मैं सभी आवश्यक पुस्तकालयों के साथ मेरी ग्रहण केपलर के लिए टूलकिट एडब्ल्यूएस स्थापित है,। http://aws.amazon.com/fr/eclipse/ .. डाउनलोड के लिए लिंक करें। NetBeans आईडीई के लिए

1

निर्देश:

  1. फ़ोल्डर /aws-java-sdk-1.9 में उदाहरण के लिए संग्रह से this पेज

  2. निकालें सभी फाइलों से डाउनलोड करें "जावा के लिए एसडीके"। अपनी परियोजना के लिए 22

  3. कॉपी अगले फ़ाइलें:

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

    • सभी * .jar फ़ोल्डर से फ़ाइलें: /aws-java-sdk-1.9.22/तीसरे पक्ष के/

  4. अब, बस सब * .jar फ़ाइलें NetBeans IDE में अपनी परियोजना में जोड़ें।

  5. लाभ!

संबंधित मुद्दे