Httpclient-4.5.2.jar ve httpcore-4.4.4.jar HttpClient bileşenlerini kullanıyorum ve hatanın altına düşüyorum.HTTPClient "main" java.lang.NoSuchFieldError: org.apache.http.conn.ssl.SSLConnectionSocketFactory adresindeki INSTANCE. <clinit>
Exception in thread "main" java.lang.NoSuchFieldError: INSTANCE
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.<clinit>(SSLConnectionSocketFactory.java:144)
at org.apache.http.impl.client.HttpClientBuilder.build(HttpClientBuilder.java:966)
Benim kaynak kodu aşağıdaki gibi.
try {
System.out.println("came to try catch");
HttpClient httpClient = HttpClientBuilder.create().build();
HttpPost request = new HttpPost("https://bizz.mobilezz.lk/apicall/loanprepaidapi/v1");
StringEntity params =new StringEntity("{\"mobile\":\"776037285\",\"path\":\"IVV\",\"loanAmount\":\"200000\"}");
request.addHeader("content-type", "application/json");
request.addHeader("Authorization", "Bearer casmk34233mlacscmaacsac");
request.addHeader("Accept", "application/json");
request.setEntity(params);
HttpResponse response = httpClient.execute(request);
System.out.println("response is :"+response.getStatusLine());
} catch (Exception e) {
e.printStackTrace();
Lütfen bu hatayı ortadan kaldırmama yardımcı olun. Postalama yönteminde istek göndermeye ve json cevabını almaya çalışıyorum.
: http://stackoverflow.com/questions/32793830/error-while-trying-to-use-an-api-java-lang-nosuchfielderror-instance – HRgiger
ben bağlantıdan çalıştı verdin. Işe yaramadı. Kavanoz dosyaları uyumluluğunu kontrol etmek için herhangi bir yolu var mı? Kavanoz dosyalarının uyumluluğunu kontrol eden birçok mesaj var. Bu kavanoz dosyalarını httpcomponents-client-4.5.2-bin'den aldım. Ama aynı zamanda işe yaramadı. – dmaprasad
Üzgünüm, bilmiyorum ama çalışan bir öğretici bulmaya çalışıyorum. yani http://crunchify.com/how-to-create-restful-java-client-using-apache-httpclient-example/, sen pom.xml httpcore burada gördüğünüz gibi ve httpclient sürümleri ile uyumlu: 4.4-beta1 – HRgiger