title: java.lang.NoClassDefFoundError: org/apache/http/ssl/TrustStrategy, though it is present in classpath
body: <p>I am running an application on tomcat server. I am getting following error while callling a specific function : </p>
  
  <p><strong>java.lang.NoClassDefFoundError: org/apache/http/ssl/TrustStrategy</strong></p>
  
  <p>My class is :</p>
  
  <pre><code>import java.io.ByteArrayOutputStream;
  import java.io.Serializable;
  import java.util.Map;
  
  import javax.net.ssl.SSLContext;
  
  import org.apache.commons.lang.StringUtils;
  import org.apache.http.HttpEntity;
  import org.apache.http.HttpHost;
  import org.apache.http.HttpResponse;
  import org.apache.http.client.HttpClient;
  import org.apache.http.client.config.RequestConfig;
  import org.apache.http.client.methods.HttpPost;
  /*import org.apache.http.client.config.AuthSchemes;
  import org.apache.http.client.config.CookieSpecs;
  import org.apache.http.client.config.RequestConfig;*/
  //import org.apache.http.client.methods.HttpPost;
  import org.apache.http.conn.ssl.NoopHostnameVerifier;
  import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
  import org.apache.http.conn.ssl.SSLContexts;
  import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
  import org.apache.http.entity.StringEntity;
  import org.apache.http.impl.client.HttpClients;
  import org.apache.http.message.BasicHeader;
  import org.apache.http.protocol.HTTP;
  import org.apache.log4j.Logger;
  import org.performics.air.business.common.data.HttpParam;
  
  public class SendAndReceiveUtil implements Serializable {
  //FIXME: move to suitable package
      /**
       * 
       */
      private static final long serialVersionUID = 2649891233958197253L;
      private static Logger LOG = Logger.getLogger(SendAndReceiveUtil.class);
  
  
      public static String httpPostWithTLS(String request,String url,Map&lt;String,String&gt; headerParameterMap){
          String responseStr = null;
          try{
              // FIXME: need to handle supplier timeout and gzip
  
              String contentType="";
              String soapAction="";               
              boolean zipForRequest=false;
              boolean acceptEncoding = false; 
              boolean zipForResponse=false;
              if (headerParameterMap!=null){
                  contentType=headerParameterMap.get(HttpParam.CONTENTTYPE.toString())!=null?headerParameterMap.get(HttpParam.CONTENTTYPE.toString()):"";
                  zipForRequest=(headerParameterMap.containsKey(HttpParam.ZIPFORREQUEST.toString()))? new Boolean(headerParameterMap.get(HttpParam.ZIPFORREQUEST.toString())):false;
                  acceptEncoding=(headerParameterMap.containsKey(HttpParam.ACCEPT_ENCODING.toString()))? new Boolean(headerParameterMap.get(HttpParam.ACCEPT_ENCODING.toString())):false;
                  zipForResponse=(headerParameterMap.containsKey(HttpParam.ZIPFORRESPONSE.toString()))? new Boolean(headerParameterMap.get(HttpParam.ZIPFORRESPONSE.toString())):false;
                  soapAction=headerParameterMap.get(HttpParam.SOAPACTION.toString())!=null?headerParameterMap.get(HttpParam.SOAPACTION.toString()):"";
              }
  
              SSLContext sslcontext = SSLContexts.custom().loadTrustMaterial(null,new TrustSelfSignedStrategy()).build();
              // Allow TLSv1.2 protocol only, use NoopHostnameVerifier to trust self-singed cert
              SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslcontext,new String[] { "TLSv1.2" }, null, new NoopHostnameVerifier());
              //do not set connection manager
              HttpClient httpclient = HttpClients.custom().setSSLSocketFactory(sslsf).build();
              HttpPost httpPost = new HttpPost(url);
              httpPost.setHeader("SOAPAction", soapAction);
  
              StringEntity mEntity = new StringEntity(request, "UTF-8");
  
              if(StringUtils.isNotBlank(contentType)){
                  mEntity.setContentType(contentType);
                  mEntity.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE,contentType));
              }else{
                  mEntity.setContentType("text/xml;charset=UTF-8");
                  mEntity.setContentEncoding(new BasicHeader(HTTP.CONTENT_ENCODING,"gzip"));
              }
              httpPost.addHeader("Content-Encoding", "gzip" );
              httpPost.addHeader("Accept-Encoding", "gzip,deflate" );
              if(null!=headerParameterMap.get("Cookie")){
                  httpPost.addHeader("Cookie", headerParameterMap.get("Cookie"));
              }
              httpPost.setEntity(mEntity);
              HttpResponse response = httpclient.execute(httpPost);
              HttpEntity et=response.getEntity();
              ByteArrayOutputStream os = new ByteArrayOutputStream();
              et.writeTo(os);
  
              responseStr = new String(os.toByteArray());
              }catch(Exception e){
                  LOG.error(e.getMessage(), e);
              }
          return responseStr;
      } 
  }
  </code></pre>
  
  <p>Error comes on calling <code>httpPostWithTLS()</code> function. I searched about it on net and found that class was available at compile but is not available at run time, but i am unable to correct it.
  I am using following http jars:</p>
  
  <ul>
  <li>commons-httpclient-3.1.jar</li>
  <li>httpclient-4.5.3.jar</li>
  <li>httpcore-4.4.6.jar</li>
  <li>httpclient-cache-4.5.3.jar</li>
  <li>httpclient-win-4.5.3.jar</li>
  <li>httpmime-4.5.3.jar</li>
  </ul>