title: JUnit - java.lang.NoSuchMethodError: org.apache.http.conn.scheme.Scheme.<init>(Ljava/lang/String;ILorg/apache/http/conn/scheme/SchemeSocketFactory;)
body: <p>I have been struggling with <code>java.lang.NoSuchMethodError: org.apache.http.conn.scheme.Scheme.&lt;init&gt;(Ljava/lang/String;ILorg/apache/http/conn/scheme/SchemeSocketFactory;)</code> while running Junit test cases in local environment. But the same test cases are running successfully in Team City build server. So far, I am skipping test cases in local development environment with </p>
  
  <pre><code>$ ./gradlew build -x test
  </code></pre>
  
  <h2>Configuration</h2>
  
  <p>As <a href="https://stackoverflow.com/a/16912105/432903">Stackoverflow post on the similar issue</a> suggests </p>
  
  <pre><code>A NoSuchMethodError indicates that classes available at runtime are different to those used to compile your code.
  </code></pre>
  
  <p>My current httpclient dependency for the module is : </p>
  
  <pre><code>compile 'org.apache.httpcomponents:httpclient:4.1.3'
  compile 'org.apache.httpcomponents:httpmime:4.1.3'
  compile 'commons-httpclient:commons-httpclient:3.1'
  </code></pre>
  
  <p>The dependency tree(minimized) is :</p>
  
  <pre><code>./gradlew -q dependencies eccount-module:dependencies
  +--- org.springframework:spring-beans:3.1.2.RELEASE
  |    \--- org.springframework:spring-core:3.1.2.RELEASE
  |         \--- org.springframework:spring-asm:3.1.2.RELEASE
  +--- org.springframework:spring-core:3.1.2.RELEASE (*)
  +--- org.springframework:spring-orm:3.1.2.RELEASE
  |    +--- org.springframework:spring-beans:3.1.2.RELEASE (*)
  |    +--- org.springframework:spring-core:3.1.2.RELEASE (*)
  |    +--- org.springframework:spring-jdbc:3.1.2.RELEASE
  |    |    +--- org.springframework:spring-beans:3.1.2.RELEASE (*)
  |    |    +--- org.springframework:spring-core:3.1.2.RELEASE (*)
  |    |    \--- org.springframework:spring-tx:3.1.2.RELEASE
  |    |         +--- aopalliance:aopalliance:1.0
  |    |         +--- org.springframework:spring-aop:3.1.2.RELEASE
  |    |         |    +--- aopalliance:aopalliance:1.0
  |    |         |    +--- org.springframework:spring-asm:3.1.2.RELEASE
  |    |         |    +--- org.springframework:spring-beans:3.1.2.RELEASE (*)
  |    |         |    \--- org.springframework:spring-core:3.1.2.RELEASE (*)
  |    |         +--- org.springframework:spring-beans:3.1.2.RELEASE (*)
  |    |         +--- org.springframework:spring-context:3.1.2.RELEASE
  |    |         |    +--- org.springframework:spring-aop:3.1.2.RELEASE (*)
  |    |         |    +--- org.springframework:spring-beans:3.1.2.RELEASE (*)
  |    |         |    +--- org.springframework:spring-core:3.1.2.RELEASE (*)
  |    |         |    +--- org.springframework:spring-expression:3.1.2.RELEASE
  |    |         |    |    \--- org.springframework:spring-core:3.1.2.RELEASE (*)
  |    |         |    \--- org.springframework:spring-asm:3.1.2.RELEASE
  |    |         \--- org.springframework:spring-core:3.1.2.RELEASE (*)
  |    \--- org.springframework:spring-tx:3.1.2.RELEASE (*)
  +--- org.springframework:spring-context:3.1.2.RELEASE (*)
  +--- org.springframework:spring-web:3.1.2.RELEASE
  |    +--- aopalliance:aopalliance:1.0
  |    +--- org.springframework:spring-beans:3.1.2.RELEASE (*)
  |    +--- org.springframework:spring-context:3.1.2.RELEASE (*)
  |    \--- org.springframework:spring-core:3.1.2.RELEASE (*)
  +--- org.springframework:spring-webmvc:3.1.2.RELEASE
  |    +--- org.springframework:spring-asm:3.1.2.RELEASE
  |    +--- org.springframework:spring-beans:3.1.2.RELEASE (*)
  |    +--- org.springframework:spring-context:3.1.2.RELEASE (*)
  |    +--- org.springframework:spring-context-support:3.1.2.RELEASE
  |    |    +--- org.springframework:spring-beans:3.1.2.RELEASE (*)
  |    |    +--- org.springframework:spring-context:3.1.2.RELEASE (*)
  |    |    \--- org.springframework:spring-core:3.1.2.RELEASE (*)
  |    +--- org.springframework:spring-core:3.1.2.RELEASE (*)
  |    +--- org.springframework:spring-expression:3.1.2.RELEASE (*)
  |    \--- org.springframework:spring-web:3.1.2.RELEASE (*)
  +--- org.springframework:spring-aop:3.1.2.RELEASE (*)
  +--- org.springframework:spring-oxm:3.1.2.RELEASE
  |    +--- commons-lang:commons-lang:2.5
  |    +--- org.springframework:spring-beans:3.1.2.RELEASE (*)
  |    +--- org.springframework:spring-context:3.1.2.RELEASE (*)
  |    \--- org.springframework:spring-core:3.1.2.RELEASE (*)
  +--- org.springframework:spring-aspects:3.1.2.RELEASE
  |    +--- org.springframework:spring-beans:3.1.2.RELEASE (*)
  |    +--- org.springframework:spring-context:3.1.2.RELEASE (*)
  |    \--- org.springframework:spring-context-support:3.1.2.RELEASE (*)
  +--- org.aspectj:aspectjweaver:1.7.0
  +--- org.springframework.security:spring-security-core:3.1.0.RELEASE
  |    +--- aopalliance:aopalliance:1.0
  |    +--- org.springframework:spring-expression:3.0.6.RELEASE -&gt; 3.1.2.RELEASE (*)
  |    +--- org.springframework:spring-aop:3.0.6.RELEASE -&gt; 3.1.2.RELEASE (*)
  |    +--- org.springframework:spring-context:3.0.6.RELEASE -&gt; 3.1.2.RELEASE (*)
  |    +--- org.springframework:spring-beans:3.0.6.RELEASE -&gt; 3.1.2.RELEASE (*)
  |    +--- org.springframework:spring-core:3.0.6.RELEASE -&gt; 3.1.2.RELEASE (*)
  |    \--- org.springframework.security:spring-security-crypto:3.1.0.RELEASE
  |         \--- org.springframework:spring-core:3.0.6.RELEASE -&gt; 3.1.2.RELEASE (*)
  +--- org.springframework.security:spring-security-web:3.1.0.RELEASE
  |    +--- org.springframework:spring-tx:3.0.6.RELEASE -&gt; 3.1.2.RELEASE (*)
  |    +--- org.springframework:spring-web:3.0.6.RELEASE -&gt; 3.1.2.RELEASE (*)
  |    +--- aopalliance:aopalliance:1.0
  |    +--- org.springframework:spring-expression:3.0.6.RELEASE -&gt; 3.1.2.RELEASE (*)
  |    +--- org.springframework:spring-aop:3.0.6.RELEASE -&gt; 3.1.2.RELEASE (*)
  |    +--- org.springframework.security:spring-security-core:3.1.0.RELEASE (*)
  |    +--- org.springframework:spring-jdbc:3.0.6.RELEASE -&gt; 3.1.2.RELEASE (*)
  |    +--- org.springframework:spring-context:3.0.6.RELEASE -&gt; 3.1.2.RELEASE (*)
  |    +--- org.springframework:spring-beans:3.0.6.RELEASE -&gt; 3.1.2.RELEASE (*)
  |    \--- org.springframework:spring-core:3.0.6.RELEASE -&gt; 3.1.2.RELEASE (*)
  +--- org.springframework.security:spring-security-config:3.1.0.RELEASE
  |    +--- org.springframework:spring-context:3.0.6.RELEASE -&gt; 3.1.2.RELEASE (*)
  |    +--- org.springframework:spring-beans:3.0.6.RELEASE -&gt; 3.1.2.RELEASE (*)
  |    +--- aopalliance:aopalliance:1.0
  |    +--- org.springframework:spring-aop:3.0.6.RELEASE -&gt; 3.1.2.RELEASE (*)
  |    +--- org.springframework.security:spring-security-core:3.1.0.RELEASE (*)
  |    \--- org.springframework:spring-core:3.0.6.RELEASE -&gt; 3.1.2.RELEASE (*)
  +--- javax.annotation:jsr250-api:1.0
  +--- org.springframework.data:spring-data-jpa:1.2.0.RELEASE
  |    +--- org.springframework.data:spring-data-commons-core:1.4.0.RELEASE
  |    |    +--- org.springframework:spring-core:3.1.2.RELEASE (*)
  |    |    \--- org.springframework:spring-beans:3.1.2.RELEASE (*)
  |    +--- org.springframework:spring-orm:3.1.2.RELEASE (*)
  |    +--- org.springframework:spring-context:3.1.2.RELEASE (*)
  |    +--- org.springframework:spring-aop:3.1.2.RELEASE (*)
  |    +--- org.springframework:spring-tx:3.1.2.RELEASE (*)
  |    +--- org.springframework:spring-beans:3.1.2.RELEASE (*)
  |    +--- org.springframework:spring-core:3.1.2.RELEASE (*)
  |    +--- org.slf4j:slf4j-api:1.6.1 -&gt; 1.6.5
  |    +--- org.slf4j:jcl-over-slf4j:1.6.1
  |    |    \--- org.slf4j:slf4j-api:1.6.1 -&gt; 1.6.5
  |    \--- org.aspectj:aspectjrt:1.6.12
  +--- org.codehaus.jackson:jackson-core-lgpl:1.9.3
  +--- org.codehaus.jackson:jackson-mapper-lgpl:1.9.3
  |    \--- org.codehaus.jackson:jackson-core-lgpl:1.9.3
  +--- org.apache.httpcomponents:httpclient:4.1.3
  |    +--- org.apache.httpcomponents:httpcore:4.1.4
  |    \--- commons-codec:commons-codec:1.4 -&gt; 1.6
  +--- org.apache.httpcomponents:httpmime:4.1.3
  |    \--- org.apache.httpcomponents:httpcore:4.1.4
  +--- commons-httpclient:commons-httpclient:3.1
  |    \--- commons-codec:commons-codec:1.2 -&gt; 1.6
  +--- commons-codec:commons-codec:1.6
  +--- commons-net:commons-net:3.1
  +--- commons-io:commons-io:1.4
  +--- commons-dbcp:commons-dbcp:20030825.184428
  +--- commons-pool:commons-pool:20030825.183949
  +--- org.apache.velocity:velocity:1.7
  |    +--- commons-collections:commons-collections:3.2.1
  |    \--- commons-lang:commons-lang:2.4 -&gt; 2.5
  +--- javax.mail:mail:1.4.4
  |    \--- javax.activation:activation:1.1
  +--- org.hibernate:hibernate-validator:4.0.0.GA
  |    +--- javax.validation:validation-api:1.0.0.GA
  |    +--- org.slf4j:slf4j-api:1.5.6 -&gt; 1.6.5
  |    +--- javax.xml.bind:jaxb-api:2.1
  |    |    +--- javax.xml.stream:stax-api:1.0-2
  |    |    \--- javax.activation:activation:1.1
  |    \--- com.sun.xml.bind:jaxb-impl:2.1.3
  |         \--- javax.xml.bind:jaxb-api:2.1 (*)
  |    +--- cglib:cglib:2.2
  |    |    \--- asm:asm:3.1
  |    +--- javassist:javassist:3.12.0.GA
  |    +--- org.hibernate.javax.persistence:hibernate-jpa-2.0-api:1.0.1.Final
  |    \--- org.slf4j:slf4j-api:1.6.1 -&gt; 1.6.5
  +--- org.hibernate.javax.persistence:hibernate-jpa-2.0-api:1.0.0.Final -&gt; 1.0.1.Final
  +--- hsqldb:hsqldb:1.8.0.10
  +--- c3p0:c3p0:0.9.1.2
  +--- com.octo.captcha:jcaptcha:2.0-alpha-1
  |    +--- com.octo.captcha:jcaptcha-api:2.0-alpha-1
  |    +--- com.jhlabs:filters:2.0.235
  |    \--- org.slf4j:slf4j-api:1.5.6 -&gt; 1.6.5
  +--- ch.qos.logback:logback-classic:1.0.6
  |    +--- ch.qos.logback:logback-core:1.0.6
  |    \--- org.slf4j:slf4j-api:1.6.5
  +--- org.springframework.ws:spring-ws-core:2.0.3.RELEASE
  |    +--- org.springframework.ws:spring-xml:2.0.3.RELEASE
  |    |    +--- org.springframework:spring-context:3.0.6.RELEASE -&gt; 3.1.2.RELEASE (*)
  |    |    +--- org.springframework:spring-core:3.0.6.RELEASE -&gt; 3.1.2.RELEASE (*)
  |    |    \--- org.springframework:spring-beans:3.0.6.RELEASE -&gt; 3.1.2.RELEASE (*)
  |    +--- org.springframework:spring-context:3.0.6.RELEASE -&gt; 3.1.2.RELEASE (*)
  |    +--- org.springframework:spring-aop:3.0.6.RELEASE -&gt; 3.1.2.RELEASE (*)
  |    +--- org.springframework:spring-oxm:3.0.6.RELEASE -&gt; 3.1.2.RELEASE (*)
  |    +--- org.springframework:spring-web:3.0.6.RELEASE -&gt; 3.1.2.RELEASE (*)
  |    +--- org.springframework:spring-webmvc:3.0.6.RELEASE -&gt; 3.1.2.RELEASE (*)
  |    +--- wsdl4j:wsdl4j:1.6.1
  |    +--- org.springframework:spring-core:3.0.6.RELEASE -&gt; 3.1.2.RELEASE (*)
  |    \--- org.springframework:spring-beans:3.0.6.RELEASE -&gt; 3.1.2.RELEASE (*)
  +--- org.springframework.ws:spring-ws-security:2.0.3.RELEASE
  |    +--- org.springframework:spring-tx:3.0.6.RELEASE -&gt; 3.1.2.RELEASE (*)
  |    +--- com.sun.xml.wsit:xws-security:1.3.1
  |    +--- com.sun.xml.wsit:wsit-rt:1.1
  |    +--- org.apache.ws.security:wss4j:1.5.8 -&gt; 1.6.4
  |    |    +--- org.apache.santuario:xmlsec:1.4.6
  |    |    \--- org.opensaml:opensaml:2.5.1-1
  |    |         \--- org.opensaml:openws:1.4.2-1
  |    |              \--- org.opensaml:xmltooling:1.3.2-1
  |    |                   +--- org.slf4j:slf4j-api:1.6.1 -&gt; 1.6.5
  |    |                   +--- joda-time:joda-time:1.6.2
  |    |                   \--- org.apache.santuario:xmlsec:1.4.4 -&gt; 1.4.6
  |    +--- org.springframework.security:spring-security-core:3.0.7.RELEASE -&gt; 3.1.0.RELEASE (*)
  |    +--- org.springframework:spring-core:3.0.6.RELEASE -&gt; 3.1.2.RELEASE (*)
  |    \--- org.springframework:spring-beans:3.0.6.RELEASE -&gt; 3.1.2.RELEASE (*)
  +--- org.springframework.ws:spring-xml:2.0.3.RELEASE (*)
  +--- aopalliance:aopalliance:1.0
  +--- org.apache.ws.security:wss4j:1.6.4 (*)
  +--- com.sun.xml.ws:webservices-rt:2.0.1
  |    \--- javax.xml:webservices-api:2.0.1
  |         \--- javax.activation:activation:1.1
  +--- xml-security:xmlsec:1.3.0
  +--- xfire:opensaml:1.0.1
  +--- net.sf.jasperreports:jasperreports:5.0.1
  |    +--- commons-beanutils:commons-beanutils:1.8.0 -&gt; 1.8.3
  |    +--- commons-collections:commons-collections:2.1 -&gt; 3.2.1
  |    +--- commons-digester:commons-digester:2.1
  |    |    \--- commons-beanutils:commons-beanutils:1.8.3
  |    +--- com.lowagie:itext:2.1.7.js1 -&gt; 2.1.7
  |    |    +--- bouncycastle:bcmail-jdk14:138
  |    |    +--- bouncycastle:bcprov-jdk14:138
  |    |    \--- bouncycastle:bctsp-jdk14:138
  |    |         \--- org.bouncycastle:bctsp-jdk14:1.38
  |    |              +--- org.bouncycastle:bcprov-jdk14:1.38
  |    |              \--- org.bouncycastle:bcmail-jdk14:1.38
  |    |                   \--- org.bouncycastle:bcprov-jdk14:1.38
  +--- org.apache.poi:poi:3.9
  |    \--- commons-codec:commons-codec:1.5 -&gt; 1.6
  +--- com.lowagie:itext:2.1.7 (*)
  +--- net.bull.javamelody:javamelody-core:1.41.0
  |    \--- org.jrobin:jrobin:1.5.9
  +--- junit:junit:4.8.2
  +--- org.springframework:spring-test:3.1.2.RELEASE
  +--- org.mockito:mockito-core:1.9.0
  |    +--- org.hamcrest:hamcrest-core:1.1
  |    \--- org.objenesis:objenesis:1.0
  </code></pre>
  
  <h2>The almighty stacktrace while running junit test case is :</h2>
  
  <pre><code>java.lang.IllegalStateException: Failed to load ApplicationContext
      at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:157)
      at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:109)
      at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:75)
      at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:321)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:211)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:288)
      at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:290)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
      at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
      at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
      at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
      at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
      at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
      at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
      at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
      at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174)
      at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
      at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
  Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'eccountJob' defined in class path resource [WEB-INF/api-context.xml]: Cannot resolve reference to bean 'eccountRequestManager' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'eccountRequestManager' defined in class path resource [WEB-INF/rest-context.xml]: Cannot resolve reference to bean 'eccountRestTemplate' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'eccountRestTemplate' defined in class path resource [WEB-INF/rest-context.xml]: Cannot create inner bean 'org.springframework.http.client.HttpComponentsClientHttpRequestFactory#2431b9' of type [org.springframework.http.client.HttpComponentsClientHttpRequestFactory] while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.http.client.HttpComponentsClientHttpRequestFactory#2431b9' defined in class path resource [WEB-INF/rest-context.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.http.client.HttpComponentsClientHttpRequestFactory]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: org.apache.http.conn.scheme.Scheme.&lt;init&gt;(Ljava/lang/String;ILorg/apache/http/conn/scheme/SchemeSocketFactory;)V
      at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
      at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
      at org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments(ConstructorResolver.java:630)
      at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:148)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1035)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:939)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
      at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:609)
      at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:469)
      at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:103)
      at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:1)
      at org.springframework.test.context.support.DelegatingSmartContextLoader.loadContext(DelegatingSmartContextLoader.java:228)
      at org.springframework.test.context.TestContext.loadApplicationContext(TestContext.java:124)
      at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:148)
      ... 24 more
  Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'eccountRequestManager' defined in class path resource [WEB-INF/rest-context.xml]: Cannot resolve reference to bean 'eccountRestTemplate' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'eccountRestTemplate' defined in class path resource [WEB-INF/rest-context.xml]: Cannot create inner bean 'org.springframework.http.client.HttpComponentsClientHttpRequestFactory#2431b9' of type [org.springframework.http.client.HttpComponentsClientHttpRequestFactory] while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.http.client.HttpComponentsClientHttpRequestFactory#2431b9' defined in class path resource [WEB-INF/rest-context.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.http.client.HttpComponentsClientHttpRequestFactory]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: org.apache.http.conn.scheme.Scheme.&lt;init&gt;(Ljava/lang/String;ILorg/apache/http/conn/scheme/SchemeSocketFactory;)V
      at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
      at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
      at org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments(ConstructorResolver.java:630)
      at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:148)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1035)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:939)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
      at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
      at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)
      ... 43 more
  Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'eccountRestTemplate' defined in class path resource [WEB-INF/rest-context.xml]: Cannot create inner bean 'org.springframework.http.client.HttpComponentsClientHttpRequestFactory#2431b9' of type [org.springframework.http.client.HttpComponentsClientHttpRequestFactory] while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.http.client.HttpComponentsClientHttpRequestFactory#2431b9' defined in class path resource [WEB-INF/rest-context.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.http.client.HttpComponentsClientHttpRequestFactory]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: org.apache.http.conn.scheme.Scheme.&lt;init&gt;(Ljava/lang/String;ILorg/apache/http/conn/scheme/SchemeSocketFactory;)V
      at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:281)
      at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:120)
      at org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments(ConstructorResolver.java:630)
      at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:148)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1035)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:939)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
      at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
      at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)
      ... 55 more
  Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.http.client.HttpComponentsClientHttpRequestFactory#2431b9' defined in class path resource [WEB-INF/rest-context.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.http.client.HttpComponentsClientHttpRequestFactory]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: org.apache.http.conn.scheme.Scheme.&lt;init&gt;(Ljava/lang/String;ILorg/apache/http/conn/scheme/SchemeSocketFactory;)V
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:997)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:943)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
      at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:270)
      ... 67 more
  Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.http.client.HttpComponentsClientHttpRequestFactory]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: org.apache.http.conn.scheme.Scheme.&lt;init&gt;(Ljava/lang/String;ILorg/apache/http/conn/scheme/SchemeSocketFactory;)V
      at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:162)
      at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:76)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:990)
      ... 71 more
  Caused by: java.lang.NoSuchMethodError: org.apache.http.conn.scheme.Scheme.&lt;init&gt;(Ljava/lang/String;ILorg/apache/http/conn/scheme/SchemeSocketFactory;)V
      at org.springframework.http.client.HttpComponentsClientHttpRequestFactory.&lt;init&gt;(HttpComponentsClientHttpRequestFactory.java:73)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
      at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:147)
      ... 73 more
  </code></pre>