2

My code is working as expected on localhost starter kit but when I deployed it to development server my below code is taking around 2-3 mins and after that it says

Invalid URL
The requested URL "http://%5bNo%20Host%5d/index.html?", is invalid.
Reference #9.3d7c4117.1550338465.3d54af04

My code is as follows:

imagePath = "https://i.imgur.com/TrNzuMY.jpg";
Image image = null;
image = ImageIO.read( new URL(imagePath))

Is this something AEM on development server is not allowing to access external URLs? This is AEM 6.3 and this code is called in a JSP which is getting called by another JSP using AJAX GET request.

Edit (After Sumanta Pakira response): This is only happening when passed URL is Secure i.e. HTTPS, for HTTP URLs it is working as expected.

Mirza
  • 369
  • 1
  • 14
  • Is the "i.imgur.com" in same AEM server or different server? – Pakira Feb 16 '19 at 20:52
  • On a different server – Mirza Feb 16 '19 at 20:59
  • Sounds like a proxy or filewall issue related to the network the dev server is connected to. – Florian Salihovic Feb 16 '19 at 21:23
  • I tried this with the image present on the same server but still the same issue. – Mirza Feb 16 '19 at 21:43
  • Is your local AEM server HTTPS enabled? I think not, and this is the reason it works in your local and you can read about CROS: https://helpx.adobe.com/experience-manager/kt/platform-repository/using/cors-security-article-understand.html – Pakira Feb 16 '19 at 22:56
  • It is working for http urls. Great catch @SumantaPakira. But I have to use https. I can't change the server config. Is there anything that can be done? – Mirza Feb 17 '19 at 00:06
  • If this is an HTTPS issue, try using an HttpClient to make the get request for testing and log the response error, there can be different reasons and this will help arrow it down. – Ahmed Musallam Feb 17 '19 at 17:36
  • This question seems to be network-related, and not really specific to ImageIO (you can reproduce the same effect using `URL.openStream()`). You might get better answers, if you re-write and re-tag it with network-related tags. – Harald K Feb 21 '19 at 10:41

1 Answers1

-1

There are two solutions :

  1. Add the server (i.imgur.com) certificate into your AEM server trust store.
  2. You can look at this example
Pakira
  • 1,951
  • 3
  • 25
  • 54