Highlighted

DefaultHttpClient is depricated in AEM-6.4

Avatar

Avatar

sunitac70336244

Avatar

sunitac70336244

sunitac70336244

18-06-2019

Dear All,

I am following the below help document for displaying data from a Restful Web Service.

Creating an Adobe Experience Manager 6.4 HTL Component that displays data from a Restful Web Service

But when I am writing the code for HeroRestComponent.java , then I am getting deprecated message , as shown below.

1774407_pastedImage_1.png

I am using AEM-6.4. Am I missing something ?

Replies

Highlighted

Avatar

Avatar

Arun_Patidar

MVP

Total Posts

2.9K

Likes

1.0K

Correct Answer

831

Avatar

Arun_Patidar

MVP

Total Posts

2.9K

Likes

1.0K

Correct Answer

831
Arun_Patidar
MVP

18-06-2019

Hi,

Please check the dependency at http://localhost:4502/system/console/depfinder 

and include in pom, for 6.4 I found below:

<dependency>

<artifactId>commons-codec</artifactId>

<version>1.10</version>

<groupId>commons-codec</groupId>

<scope>provided</scope>

</dependency>

Highlighted

Avatar

Avatar

Veena_Vikram

MVP

Avatar

Veena_Vikram

MVP

Veena_Vikram
MVP

18-06-2019

Hi Sunitha

  Please check this blog https://www.mkyong.com/java/the-type-defaulthttpclient-is-deprecated/  . This talks about the same issue. I also tried the same. You can rewrite the code like below

HttpClient client = HttpClientBuilder.create().build(); 

HttpGet getRequest = new HttpGet("http://services.groupkt.com/country/get/iso2code/"+code);

getRequest.addHeader("accept", "application/json");

HttpResponse response = client.execute(getRequest);

PS:- I have not executed the code. But guess this should work from little bit of googling Happy coding .

Thanks

Veena

Highlighted

Avatar

Avatar

Jörg_Hoh

Employee

Total Posts

3.0K

Likes

910

Correct Answer

1.0K

Avatar

Jörg_Hoh

Employee

Total Posts

3.0K

Likes

910

Correct Answer

1.0K
Jörg_Hoh
Employee

18-06-2019

I just checked (AEM 6.5, but 6.4 should be very similar), and there is a bundle "org.apache.httpcomponents.httpclient", which exports the java namespaces "org.apache.http.{auth,client,conn, impl}". You should be able to adapt your code to fix this deprecation easily.

(If it's working can you raise a ticket with Adobe support and ask if this example can be adapted? Thanks!)

Jörg