Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

DefaultHttpClient is depricated in AEM-6.4

sunitac70336244
Level 4
Level 4

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 ?

0 Replies
Arun_Patidar
Community Advisor
Community Advisor

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>

Veena_Vikram
Community Advisor
Community Advisor

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

Jörg_Hoh
Employee
Employee

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