HTTPClient “main” java.lang.NoSuchFieldError: INSTANCE à org.apache.http.conn.ssl.SSLConnectionSocketFactory.

J’utilise les composants HttpClient-Httpclient-4.5.2.jar et httpcore-4.4.4.jar et j’obtiens une erreur en dessous.

Exception in thread "main" java.lang.NoSuchFieldError: INSTANCE at org.apache.http.conn.ssl.SSLConnectionSocketFactory.(SSLConnectionSocketFactory.java:144) at org.apache.http.impl.client.HttpClientBuilder.build(HttpClientBuilder.java:966) 

Mon code source comme suit.

 try { System.out.println("came to try catch"); HttpClient httpClient = HttpClientBuilder.create().build(); HttpPost request = new HttpPost("https://bizz.mobilezz.lk/apicall/loanprepaidapi/v1"); SsortingngEntity params =new SsortingngEntity("{\"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(); 

S’il vous plaît, aidez-moi à éliminer cette erreur. J’essaye d’envoyer la demande dans la méthode post et d’obtenir une réponse json.

J’ai trouvé une réponse à ma question et poster pour votre référence.

 HttpClient client = new DefaultHttpClient(); HttpPost post = new HttpPost( "https://bizz.mobilezz.lk/apicall/loanprepaidapi/v1"); JSONObject json = new JSONObject(); SsortingngEntity params = new SsortingngEntity("{\"msisdn\":\"" + mobile + "\",\"channel\":\"SDD\"}"); new SsortingngEntity(json.toSsortingng()); post.addHeader("Host", "mife.dialog.lk"); post.addHeader("content-type", "application/json"); post.addHeader("Authorization", "Bearer " + access_token); post.addHeader("Accept", "application/json"); // System.out.println("status code is:" + status); post.setEntity(params); HttpResponse response = client.execute(post); int status = response.getStatusLine().getStatusCode(); System.out.println("status code is :" + status); resCode = Integer.toSsortingng(status); if (status != 401) { if (status != 409) { BufferedReader rd = new BufferedReader( new InputStreamReader(response.getEntity() .getContent())); Ssortingng response1 = readAll(rd); System.out.println(response1); JSONObject obj = new JSONObject(response1); resCode = obj.getSsortingng("resCode"); resDesc = obj.getSsortingng("resDesc"); System.out.println(resCode); System.out.println(resDesc); } } System.out.println("reason code is :" + resCode);