title: Getting NoSuchMethodError on HttpClients.custom().setConnectionManagerShared(true).build()
body: <p>I am trying to create a HTTP connection with a URL in a EJB and the below line of code was throwing error</p>
  
  <pre><code>HttpClients.custom().setConnectionManagerShared(true).build();
  </code></pre>
  
  <p>ERROR:</p>
  
  <pre><code>java.lang.NoSuchMethodError: org.apache.http.impl.client.HttpClientBuilder.setConnectionManagerShared(Z)Lorg/apache/http/impl/client/HttpClientBuilder;
  </code></pre>
  
  <p>Initially I did not specify which version of HttpClient, so I added the GAV to my pom.xml</p>
  
  <pre><code>&lt;dependency&gt;
    &lt;groupId&gt;org.apache.httpcomponents&lt;/groupId&gt;
    &lt;artifactId&gt;httpclient&lt;/artifactId&gt;
    &lt;version&gt;4.5.2&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>I ensured the war file had that jar. There was no error in Eclipse during compile time.</p>
  
  <p>But whenever I execute it I am getting the NoSuchMethodError. I am using Java version 1.8.0_131. </p>
  
  <p>I am totally confused because if I didn't get that error on compile time, why am I getting it on Runtime? Any help is greatly appreciated</p>