Wednesday, September 18, 2013

"Unable to execute HTTP request: Connection to https://ec2.amazonaws.com refused" error while executing AWS Java SDK Sample projects

If you are behind proxy then these sample projects will not read proxy from eclipse proxy settings.

to fix this issue you have to add some extra lines of code into your sample projects.


Create a object of ClientConfiguration class and set proxyhost and proxyport properties and then pass this object while creating client (ec2,S3  or sdb etc)

so your init method should look something like this after modification


 private static void init() throws Exception {
    /*
* This credentials provider implementation loads your AWS credentials
* from a properties file at the root of your classpath.
*
*/
   
    ClientConfiguration clientCfg = new ClientConfiguration();
        clientCfg.setProtocol(Protocol.HTTP);

        //setup proxy connection:
        clientCfg.setProxyHost("HTTP_PROXY_IP");
        clientCfg.setProxyPort(8080);
       
        AWSCredentialsProvider credentialsProvider = new ClasspathPropertiesFileCredentialsProvider();

        ec2 = new AmazonEC2Client(credentialsProvider,clientCfg);
        s3  = new AmazonS3Client(credentialsProvider,clientCfg);
        sdb = new AmazonSimpleDBClient(credentialsProvider,clientCfg);
    }

"Missing requirement: Eclipse Data Tools Platform Amazon SimpleDB UI Plug-in 1.0.0.v201308121803" Error while installing AWS Toolkit for Eclipse

In Eclipse follow below steps to fix this

1: Help -> install new software
2: Type "http://download.eclipse.org/releases/kepler" in the url field
3: Select "Database Development"  and install from the list.
4:  Try to re install  AWS Toolkit, it will work..   :)