title: Apache httpclient 4.3.1 java.lang.NoSuchFieldError: INSTANCE
body: <p>I am developing a Java EE web application.</p>
  
  <p>here is my pom.xml:</p>
  
  <pre><code>&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/maven-v4_0_0.xsd"&gt;
  
  &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  &lt;groupId&gt;bitcoin&lt;/groupId&gt;
  &lt;artifactId&gt;bitcoin&lt;/artifactId&gt;
  &lt;packaging&gt;war&lt;/packaging&gt;
  &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
  &lt;name&gt;Chens Bitcoin Webapp&lt;/name&gt;
  &lt;url&gt;http://maven.apache.org&lt;/url&gt;
  
  &lt;properties&gt;
      &lt;endorsed.dir&gt;${project.build.directory}/endorsed&lt;/endorsed.dir&gt;
      &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
      &lt;!-- Define the version of the JBoss BOMs we want to import to specify tested stacks. --&gt;
      &lt;version.jboss.bom&gt;1.0.5.CR6&lt;/version.jboss.bom&gt;
  &lt;/properties&gt;
  
  &lt;repositories&gt;
      &lt;repository&gt;
          &lt;id&gt;prime-repo&lt;/id&gt;
          &lt;name&gt;Prime Repo&lt;/name&gt;
          &lt;url&gt;http://repository.primefaces.org&lt;/url&gt;
      &lt;/repository&gt;
  &lt;/repositories&gt;
  
  &lt;dependencyManagement&gt;
      &lt;dependencies&gt;
          &lt;!-- Define the version of JBoss' Java EE 6 APIs we want to use --&gt;
          &lt;!-- JBoss distributes a complete set of Java EE 6 APIs including
              a Bill of Materials (BOM). A BOM specifies the versions of a "stack" (or
              a collection) of artifacts. We use this here so that we always get the correct
              versions of artifacts. Here we use the jboss-javaee-6.0-with-security stack
              (you can read this as the JBoss stack of the Java EE 6 APIs with Security).
              You can actually use this stack with any version of JBoss AS that implements
              Java EE 6, not just JBoss AS 7! --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.jboss.bom&lt;/groupId&gt;
              &lt;artifactId&gt;jboss-javaee-6.0-with-security&lt;/artifactId&gt;
              &lt;version&gt;${version.jboss.bom}&lt;/version&gt;
              &lt;type&gt;pom&lt;/type&gt;
              &lt;scope&gt;import&lt;/scope&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  &lt;/dependencyManagement&gt;
  </code></pre>
  
  <p></p>
  
  <pre><code>  &lt;dependency&gt;
        &lt;groupId&gt;javax&lt;/groupId&gt;
        &lt;artifactId&gt;javaee-web-api&lt;/artifactId&gt;
        &lt;version&gt;7.0&lt;/version&gt;
        &lt;scope&gt;provided&lt;/scope&gt;
    &lt;/dependency&gt;
  
    &lt;!--&lt;dependency&gt;--&gt;
        &lt;!--&lt;groupId&gt;org.jboss.spec.javax.faces&lt;/groupId&gt;--&gt;
        &lt;!--&lt;artifactId&gt;jboss-jsf-api_2.2_spec&lt;/artifactId&gt;--&gt;
        &lt;!--&lt;version&gt;2.2.0&lt;/version&gt;--&gt;
    &lt;!--&lt;/dependency&gt;--&gt;
  
    &lt;!--&lt;dependency&gt;--&gt;
        &lt;!--&lt;groupId&gt;com.sun.faces&lt;/groupId&gt;--&gt;
        &lt;!--&lt;artifactId&gt;jsf-spi&lt;/artifactId&gt;--&gt;
        &lt;!--&lt;version&gt;1.0&lt;/version&gt;--&gt;
    &lt;!--&lt;/dependency&gt;--&gt;
  
    &lt;!-- Rewrite --&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;org.ocpsoft.rewrite&lt;/groupId&gt;
        &lt;artifactId&gt;rewrite-servlet&lt;/artifactId&gt;
        &lt;version&gt;2.0.8.Final&lt;/version&gt;
    &lt;/dependency&gt;
  
    &lt;dependency&gt;
        &lt;groupId&gt;org.ocpsoft.rewrite&lt;/groupId&gt;
        &lt;artifactId&gt;rewrite-config-prettyfaces&lt;/artifactId&gt;
        &lt;version&gt;2.0.8.Final&lt;/version&gt;
    &lt;/dependency&gt;
  
    &lt;dependency&gt;
        &lt;groupId&gt;org.omnifaces&lt;/groupId&gt;
        &lt;artifactId&gt;omnifaces&lt;/artifactId&gt;
        &lt;version&gt;1.6&lt;/version&gt;
    &lt;/dependency&gt;
  
    &lt;dependency&gt;
        &lt;groupId&gt;commons-fileupload&lt;/groupId&gt;
        &lt;artifactId&gt;commons-fileupload&lt;/artifactId&gt;
        &lt;version&gt;1.3&lt;/version&gt;
    &lt;/dependency&gt;
  
    &lt;dependency&gt;
        &lt;groupId&gt;org.primefaces&lt;/groupId&gt;
        &lt;artifactId&gt;primefaces&lt;/artifactId&gt;
        &lt;version&gt;3.5&lt;/version&gt;
    &lt;/dependency&gt;
  
    &lt;!-- Data time management --&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;joda-time&lt;/groupId&gt;
        &lt;artifactId&gt;joda-time&lt;/artifactId&gt;
        &lt;version&gt;2.2&lt;/version&gt;
    &lt;/dependency&gt;
  
    &lt;dependency&gt;
        &lt;groupId&gt;commons-codec&lt;/groupId&gt;
        &lt;artifactId&gt;commons-codec&lt;/artifactId&gt;
        &lt;version&gt;1.9&lt;/version&gt;
    &lt;/dependency&gt;
  
    &lt;dependency&gt;
        &lt;groupId&gt;org.apache.httpcomponents&lt;/groupId&gt;
        &lt;artifactId&gt;httpclient&lt;/artifactId&gt;
        &lt;version&gt;4.3.1&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;version&gt;1.1.1&lt;/version&gt;
    &lt;/dependency&gt;
  
    &lt;!-- Import the PicketLink API, we deploy this as library with the application,
          and can compile against it --&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;org.picketlink&lt;/groupId&gt;
        &lt;artifactId&gt;picketlink-core-api&lt;/artifactId&gt;
    &lt;/dependency&gt;
  
    &lt;!-- Import the PicketLink implementation, we deploy this as library with the application,
        but can't compile against it --&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;org.picketlink&lt;/groupId&gt;
        &lt;artifactId&gt;picketlink-core-impl&lt;/artifactId&gt;
        &lt;scope&gt;runtime&lt;/scope&gt;
    &lt;/dependency&gt;
  
  &lt;dependency&gt;
    &lt;groupId&gt;junit&lt;/groupId&gt;
    &lt;artifactId&gt;junit&lt;/artifactId&gt;
    &lt;version&gt;3.8.1&lt;/version&gt;
    &lt;scope&gt;test&lt;/scope&gt;
    &lt;/dependency&gt;
    &lt;/dependencies&gt;
    &lt;build&gt;
    &lt;finalName&gt;bitcoin&lt;/finalName&gt;
    &lt;plugins&gt;
        &lt;plugin&gt;
            &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
            &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
            &lt;version&gt;3.1&lt;/version&gt;
            &lt;configuration&gt;
                &lt;source&gt;1.7&lt;/source&gt;
                &lt;target&gt;1.7&lt;/target&gt;
                &lt;compilerArguments&gt;
                    &lt;endorseddirs&gt;${endorsed.dir}&lt;/endorseddirs&gt;
                &lt;/compilerArguments&gt;
            &lt;/configuration&gt;
        &lt;/plugin&gt;
        &lt;plugin&gt;
            &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
            &lt;artifactId&gt;maven-war-plugin&lt;/artifactId&gt;
            &lt;version&gt;2.3&lt;/version&gt;
            &lt;configuration&gt;
                &lt;failOnMissingWebXml&gt;false&lt;/failOnMissingWebXml&gt;
            &lt;/configuration&gt;
        &lt;/plugin&gt;
        &lt;plugin&gt;
            &lt;groupId&gt;org.jboss.as.plugins&lt;/groupId&gt;
            &lt;artifactId&gt;jboss-as-maven-plugin&lt;/artifactId&gt;
            &lt;version&gt;7.4.Final&lt;/version&gt;
        &lt;/plugin&gt;
        &lt;plugin&gt;
            &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
            &lt;artifactId&gt;maven-dependency-plugin&lt;/artifactId&gt;
            &lt;version&gt;2.6&lt;/version&gt;
            &lt;executions&gt;
                &lt;execution&gt;
                    &lt;phase&gt;validate&lt;/phase&gt;
                    &lt;goals&gt;
                        &lt;goal&gt;copy&lt;/goal&gt;
                    &lt;/goals&gt;
                    &lt;configuration&gt;
                        &lt;outputDirectory&gt;${endorsed.dir}&lt;/outputDirectory&gt;
                        &lt;silent&gt;true&lt;/silent&gt;
                        &lt;artifactItems&gt;
                            &lt;artifactItem&gt;
                                &lt;groupId&gt;javax&lt;/groupId&gt;
                                &lt;artifactId&gt;javaee-endorsed-api&lt;/artifactId&gt;
                                &lt;version&gt;7.0&lt;/version&gt;
                                &lt;type&gt;jar&lt;/type&gt;
                            &lt;/artifactItem&gt;
                        &lt;/artifactItems&gt;
                    &lt;/configuration&gt;
                &lt;/execution&gt;
            &lt;/executions&gt;
        &lt;/plugin&gt;
    &lt;/plugins&gt;
  &lt;/build&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>I have a method to create HttpClient, it works fine alone, but having problem when calling from jsf page:</p>
  
  <pre><code>  public void doSth() {
    ......
    HttpClient httpclient = HttpClientBuilder.create().build();
    ......
    }
  </code></pre>
  
  <p>this method is invoked by commonbutton on JSF page, when button clicked following error occurred:</p>
  
  <pre><code>      Caused by: java.lang.NoSuchFieldError: INSTANCE
      at org.apache.http.impl.io.DefaultHttpRequestWriterFactory.&lt;init&gt;(DefaultHttpRequestWriterFactory.java:52) [httpcore-4.3.jar:4.3]
      at org.apache.http.impl.io.DefaultHttpRequestWriterFactory.&lt;init&gt;(DefaultHttpRequestWriterFactory.java:56) [httpcore-4.3.jar:4.3]
      at org.apache.http.impl.io.DefaultHttpRequestWriterFactory.&lt;clinit&gt;(DefaultHttpRequestWriterFactory.java:46) [httpcore-4.3.jar:4.3]
        ......
  </code></pre>
  
  <p>googled it, seems httpclient jar file has conflict with some other class, but I really can't figure out which one, and all dependencies in pom are necessary. </p>
  
  <p>BTW, I am using WildFly 8 CR as server.</p>
  
  <p>Thanks in advance.</p>