Bug 64325 - Import as remote by url fails.
Summary: Import as remote by url fails.
Status: RESOLVED WORKSFORME
Alias: None
Product: Ant
Classification: Unclassified
Component: Build Process (show other bugs)
Version: 1.10.7
Hardware: PC All
: P2 major (vote)
Target Milestone: ---
Assignee: Ant Notifications List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-04-09 13:10 UTC by Tomáš
Modified: 2020-08-23 10:34 UTC (History)
0 users



Attachments
Build file to reproduce the issue (232 bytes, text/xml)
2020-04-09 13:10 UTC, Tomáš
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tomáš 2020-04-09 13:10:37 UTC
Created attachment 37159 [details]
Build file to reproduce the issue

Trying to import remote ant file fails when importing from https://gitlab.com/.. .

Build file to reproduce the issue is attached.

JDK version: 1.8.0_212
Ant version: 1.10.7

Error message generated:
Cannot find https://gitlab.com/MedisoArt/public/java-commons/raw/master/build.xml imported from [local build.xml].

Important notes:
1. Importing from other servers works as expected.
2. Importing from gitlab worked as expected on 23 March 2020. Now it fails.
Comment 1 Jaikiran Pai 2020-05-04 03:22:01 UTC
This looks like some server side change/policy that that URL might have placed. I can access that URL from browser, curl and wget but when Ant tries it from Java code, it's receiving a 403 error. In fact, even the following trivial Java program (which is almost what Ant does internally) results in a 403:

import java.net.URL;
import java.io.InputStream;

public class Fetch {
     public static void main(final String[] args) throws Exception {
     	final URL targetURL = new URL("https://gitlab.com/MedisoArt/public/java-commons/raw/master/build.xml");
         try (final InputStream is = targetURL.openConnection().getInputStream()) {
             is.read();
         }
         System.out.println("Done");
     }
}

You might have to talk to whoever manages that URL to understand what restrictions are in place to access that URL (and what changed on 23 March 2020). Maybe they are using some request headers to decide whether or not to allow access to the resource.
Comment 2 Jaikiran Pai 2020-05-04 03:22:58 UTC
This is the error that I get when I run that trivial Java program:

Exception in thread "main" java.io.IOException: Server returned HTTP response code: 403 for URL: https://gitlab.com/MedisoArt/public/java-commons/raw/master/build.xml
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1900)
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1498)
	at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:268)
Comment 3 Stefan Bodewig 2020-08-23 10:34:44 UTC
It works with Java 14 but not with Java 8. It seems some server side configuration is prohibiting Java8 - the TLS handshake looks fine, though.