java.lang.NoSuchFieldError: org.apache.http.message.BasicLineFormatter.INSTANCE from Mashape Unirest in Java application

前端 未结 5 614
半阙折子戏
半阙折子戏 2020-11-29 22:45

I have a Maven Java project that uses Mashape Unirest for sending HTTP requests to other URLs. I am currently writing an integration test (using TestNG) tha

5条回答
  •  时光取名叫无心
    2020-11-29 23:05

    I faced the same exception using unirest:

    java.lang.NoSuchFieldError: INSTANCE
            at org.apache.http.impl.io.DefaultHttpRequestWriterFactory.(DefaultHttpRequestWriterFactory.java:52)
    at com.mashape.unirest.http.options.Options.refresh(Options.java:55)
    at com.mashape.unirest.http.options.Options.(Options.java:36)
    

    And found it was due to DefaultConnectionKeepAliveStrategy.INSTANCE; and the conflicting jar was apache-httpcomponents-httpclient.jar in my classpath. Adding this post to help anyone who faces similar exception

提交回复
热议问题