title: Spring with ElastiCache. Not able to instantiate AmazonElastiCacheClient error
body: <p>I am trying to write a basic hello app with Spring Cloud AWS to test out Redis through Elasticache support in Spring Cloud.
  As soon as I add the following line to my configuration XML my build is failing.</p>
  
  <pre><code>&lt;aws-cache:cache-manager&gt;
          &lt;aws-cache:cache-cluster name="CacheCluster" /&gt;
      &lt;/aws-cache:cache-manager&gt;
  </code></pre>
  
  <p>This is the error I am getting.</p>
  
  <pre><code>Error creating bean with name 'dataSourceInitializerPostProcessor': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.beans.factory.BeanFactory org.springframework.boot.autoconfigure.jdbc.DataSourceInitializerPostProcessor.beanFactory; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'amazonElastiCache': Unsatisfied dependency expressed through constructor argument with index 0 of type [java.lang.Class]: Could not convert constructor argument value of type [java.lang.String] to required type [java.lang.Class]: Failed to convert value of type 'java.lang.String' to required type 'java.lang.Class'; nested exception is java.lang.IllegalArgumentException: Cannot find class [com.amazonaws.services.elasticache.AmazonElastiCacheClient]
  </code></pre>
  
  <p>I tried explicity adding the dependency for AWS Elasticache libray into my POM, but only made it even worse.</p>
  
  <pre><code>&lt;dependency&gt;
          &lt;groupId&gt;com.amazonaws&lt;/groupId&gt;
          &lt;artifactId&gt;aws-java-sdk-elasticache&lt;/artifactId&gt;
          &lt;version&gt;1.9.15&lt;/version&gt;
      &lt;/dependency&gt;
  </code></pre>
  
  <p>This is the error I am getting after the POM change.</p>
  
  <pre><code>Error creating bean with name 'springBootAwsApplication': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: org.springframework.jdbc.core.JdbcTemplate base.SpringBootAwsApplication.jdbcTemplate; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration$JdbcTemplateConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private javax.sql.DataSource org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration$JdbcTemplateConfiguration.dataSource; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'springrds': Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: com.amazonaws.AmazonWebServiceClient.beforeMarshalling(Lcom/amazonaws/AmazonWebServiceRequest;)Lcom/amazonaws/AmazonWebServiceRequest;
  </code></pre>
  
  <p>This is my POM.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
  &lt;groupId&gt;org.nyn&lt;/groupId&gt;
  &lt;artifactId&gt;spring-boot-aws&lt;/artifactId&gt;
  &lt;version&gt;0.0.5-SNAPSHOT&lt;/version&gt;
  &lt;packaging&gt;war&lt;/packaging&gt;
  
  &lt;name&gt;spring-boot-aws&lt;/name&gt;
  &lt;description&gt;Demo project for Spring Cloud AWS&lt;/description&gt;
  
  &lt;parent&gt;
      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
      &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
      &lt;version&gt;1.2.5.RELEASE&lt;/version&gt;
      &lt;relativePath /&gt; &lt;!-- lookup parent from repository --&gt;
  &lt;/parent&gt;
  
  &lt;properties&gt;
      &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
      &lt;java.version&gt;1.8&lt;/java.version&gt;
  &lt;/properties&gt;
  
  &lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-actuator&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-jdbc&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-remote-shell&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-tomcat&lt;/artifactId&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;exclusions&gt;
              &lt;exclusion&gt;
                  &lt;artifactId&gt;tools&lt;/artifactId&gt;
                  &lt;groupId&gt;com.sun&lt;/groupId&gt;
              &lt;/exclusion&gt;
          &lt;/exclusions&gt;
          &lt;groupId&gt;com.basho.riak&lt;/groupId&gt;
          &lt;artifactId&gt;riak-client&lt;/artifactId&gt;
          &lt;version&gt;2.0.0&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.codehaus.plexus&lt;/groupId&gt;
          &lt;artifactId&gt;plexus-utils&lt;/artifactId&gt;
          &lt;version&gt;3.0.15&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;
          &lt;artifactId&gt;spring-cloud-aws-jdbc&lt;/artifactId&gt;
          &lt;version&gt;1.0.2.RELEASE&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.jboss.spec.javax.resource&lt;/groupId&gt;
          &lt;artifactId&gt;jboss-connector-api_1.5_spec&lt;/artifactId&gt;
          &lt;version&gt;1.0.0.Final&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;mysql&lt;/groupId&gt;
          &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;
          &lt;artifactId&gt;spring-cloud-aws-context&lt;/artifactId&gt;
          &lt;version&gt;1.0.2.RELEASE&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-data-mongodb&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-data-rest&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.igniterealtime.smack&lt;/groupId&gt;
          &lt;artifactId&gt;smack-core&lt;/artifactId&gt;
          &lt;version&gt;4.0.0&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.igniterealtime.smack&lt;/groupId&gt;
          &lt;artifactId&gt;smack-tcp&lt;/artifactId&gt;
          &lt;version&gt;4.0.0&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.googlecode.json-simple&lt;/groupId&gt;
          &lt;artifactId&gt;json-simple&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.data&lt;/groupId&gt;
          &lt;artifactId&gt;spring-data-redis&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;redis.clients&lt;/groupId&gt;
          &lt;artifactId&gt;jedis&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.amazonaws&lt;/groupId&gt;
          &lt;artifactId&gt;aws-java-sdk-elasticache&lt;/artifactId&gt;
          &lt;version&gt;1.9.15&lt;/version&gt;
      &lt;/dependency&gt;
  &lt;/dependencies&gt;
  
  &lt;build&gt;
      &lt;plugins&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
              &lt;configuration&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;
              &lt;configuration&gt;
                  &lt;skipTests&gt;false&lt;/skipTests&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  &lt;/build&gt;
  </code></pre>
  
  <p></p>
  
  <p>This is what I have in config.xml</p>
  
  <pre><code>    &lt;aws-context:context-credentials&gt;
      &lt;aws-context:simple-credentials
          access-key="$accesskey" secret-key="$secret" /&gt;
  &lt;/aws-context:context-credentials&gt;
  &lt;aws-context:context-region region="$region" /&gt;
  &lt;aws-jdbc:data-source 
      db-instance-identifier="$rdsid" password="$rdspassword"&gt;
      &lt;aws-jdbc:pool-attributes initialSize="1" defaultCatalog="Records"
                        testOnBorrow="true" validationQuery="SELECT 1" /&gt;
  &lt;/aws-jdbc:data-source&gt;
  &lt;aws-cache:cache-manager&gt;
      &lt;aws-cache:cache-cluster name="CacheCluster" /&gt;
  &lt;/aws-cache:cache-manager&gt;
  </code></pre>
  
  <p></p>
  
  <p>And here is my main() class.</p>
  
  <pre><code>@SpringBootApplication
  @EnableAutoConfiguration
  @ComponentScan
  @Configuration
  @ImportResource("classpath:aws-config.xml")
  
  public class SpringBootAwsApplication {
  
  @Autowired
  JdbcTemplate jdbcTemplate;
  
  public static void main(String[] args) {
      SpringApplication.run(SpringBootAwsApplication.class, args);
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Poking around it further, I am now stuck with this error.</p>
  
  <pre><code>org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'amazonElastiCache': Invocation of init method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.amazonaws.services.elasticache.AmazonElastiCacheClient]: Constructor threw exception; nested exception is java.lang.NoSuchFieldError: requestHandlers
  </code></pre>
  
  <p>which basically says it can't create a bean named <code>amazonElastiCache</code> with an error in constructor which is missing a field <code>requestHandlers</code>.
  Can anybody tell me how to properly instantiate <code>amazonElastiCache</code> ?</p>