DefaultHttpClient is depricated in AEM-6.4

Avatar

Avatar
Validate 10
Level 2
sunitac70336244
Level 2

Likes

7 likes

Total Posts

65 posts

Correct reply

1 solution
Top badges earned
Validate 10
Validate 1
Boost 5
Boost 3
Boost 1
View profile

Avatar
Validate 10
Level 2
sunitac70336244
Level 2

Likes

7 likes

Total Posts

65 posts

Correct reply

1 solution
Top badges earned
Validate 10
Validate 1
Boost 5
Boost 3
Boost 1
View profile
sunitac70336244
Level 2

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

Avatar

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,442 likes

Total Posts

3,318 posts

Correct reply

941 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,442 likes

Total Posts

3,318 posts

Correct reply

941 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile
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>

Avatar

Avatar
Establish
MVP
Veena_Vikram
MVP

Likes

484 likes

Total Posts

1,049 posts

Correct reply

121 solutions
Top badges earned
Establish
Coach
Contributor 2
Seeker
Ignite 5
View profile

Avatar
Establish
MVP
Veena_Vikram
MVP

Likes

484 likes

Total Posts

1,049 posts

Correct reply

121 solutions
Top badges earned
Establish
Coach
Contributor 2
Seeker
Ignite 5
View profile
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

Avatar

Avatar
Coach
Employee
Jörg_Hoh
Employee

Likes

1,134 likes

Total Posts

3,161 posts

Correct reply

1,079 solutions
Top badges earned
Coach
Give back 600
Ignite 5
Ignite 3
Ignite 1
View profile

Avatar
Coach
Employee
Jörg_Hoh
Employee

Likes

1,134 likes

Total Posts

3,161 posts

Correct reply

1,079 solutions
Top badges earned
Coach
Give back 600
Ignite 5
Ignite 3
Ignite 1
View profile
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