HTTPClient Example – Exception in thread “main” java.lang.NoSuchFieldError: INSTANCE

I had this problem with Hadoop. It used an old version of httpclient-4.2.5.jar and httpcore-4.2.5.jar in their shared lib.

I solved this by shading parts via the maven-shade-plugin

<relocations>
    <relocation>
        <pattern>org.apache.http</pattern>
        <shadedPattern>shaded.org.apache.http</shadedPattern>
    </relocation>
</relocations>

Leave a Comment