title: Could not initialize class org.apache.http.impl.conn.ManagedHttpClientConnectionFactory
body: <p>I'm working on webservice and I have a issue like below:</p>
  
  <blockquote>
    <p>org.jboss.resteasy.spi.UnhandledException:
    java.lang.NoClassDefFoundError: Could not initialize class
    org.apache.http.impl.conn.ManagedHttpClientConnectionFactory
      org.jboss.resteasy.core.SynchronousDispatcher.unwrapException(SynchronousDispatcher.java:345)
      org.jboss.resteasy.core.SynchronousDispatcher.handleApplicationException(SynchronousDispatcher.java:321)
      org.jboss.resteasy.core.SynchronousDispatcher.handleException(SynchronousDispatcher.java:214)
      org.jboss.resteasy.core.SynchronousDispatcher.handleInvokerException(SynchronousDispatcher.java:190)
      org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:534)
      org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:496)
      org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:119)
      org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208)
      org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55)
      org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)</p>
    
    <p>root cause </p>
    
    <p>java.lang.NoClassDefFoundError: Could not initialize class
    org.apache.http.impl.conn.ManagedHttpClientConnectionFactory
      org.apache.http.impl.conn.PoolingHttpClientConnectionManager$InternalConnectionFactory.(PoolingHttpClientConnectionManager.java:487)
      org.apache.http.impl.conn.PoolingHttpClientConnectionManager.(PoolingHttpClientConnectionManager.java:147)
      org.apache.http.impl.conn.PoolingHttpClientConnectionManager.(PoolingHttpClientConnectionManager.java:136)
      org.apache.http.impl.conn.PoolingHttpClientConnectionManager.(PoolingHttpClientConnectionManager.java:112)
      org.apache.http.impl.client.HttpClientBuilder.build(HttpClientBuilder.java:727)
      org.apache.http.impl.client.HttpClients.createDefault(HttpClients.java:58)
      com.cns.atta.rest.actions.attaFileUploadActions.uploadToGSFS(attaFileUploadActions.java:443)
      com.cns.atta.rest.actions.attaFileUploadActions.doRequiredWorks(attaFileUploadActions.java:197)
      com.cns.atta.rest.actions.attaFileUploadActions.uploadFileXML(attaFileUploadActions.java:89)
      sun.reflect.GeneratedMethodAccessor501.invoke(Unknown Source)
      sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      java.lang.reflect.Method.invoke(Method.java:616)
      org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:140)
      org.jboss.resteasy.core.ResourceMethod.invokeOnTarget(ResourceMethod.java:255)
      org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:220)
      org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:209)
      org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:519)
      org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:496)
      org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:119)
      org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208)
      org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55)
      org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)</p>
  </blockquote>
  
  <h2>Please note that the full stack trace of the root cause is available in the JBoss Web/2.1.10 logs.</h2>
  
  <p>Library is /jboss-eap-5.1/resteasy/lib/httpclient-4.0.jar"/. Application runs on Jboss 5 EAP server servlet container. It will be deployed to a server as a war file.</p>
  
  <p>In that there is missing class <code>managedHttpClientConnectionFactory</code>.</p>
  
  <p>My question is that I can use httpclient-4.3.jar for Jboss 5 EAP right? because in that this class is available or there is another solution to avoid this error.
  Any Idea about this?</p>
  
  <p>Code is:</p>
  
  <pre><code>Line number 443 :   CloseableHttpClient client =     HttpClients.createDefault();
  
      try {
          HttpPost postRequest = new HttpPost(attaActionContextListener
                  .getINSTANCE().getGsfsAddress());
          // Set various attributes
          // FileBody fileBody = new FileBody(file);
          HttpEntity reqEntity = null; ...
  </code></pre>
  
  <p>Line number 197 : parseServerResponse(uploadToGSFS(model, actionType), model);
  Line number 89 : return doRequiredWorks(input, ActionType.INSERT);</p>