3
votes

I am facing a problem with Artifactory v3.9.5 resolving artifacts. I have the following setup:

  • local repository called "gradle-snaphot" allowed for snapshots
  • virtual repository called "repos" that includes "gradle-snapshot"
  • an artifact X uploaded to "gradle-snapshot"

Now, when I try to get the artifact directly, it works fine (credantials passed but omitted here):

wget http://myrepo/artifactory/gradle-snapshot/x/SNAPSHOT/maven-metadata.xml?trace

But when I try to get the artifact via the virtual repository, then it doesn't work:

wget http://myrepo/artifactory/repos/x/SNAPSHOT/maven-metadata.xml?trace

wget output is:

Resolving myrepo... xx.xxx.xxx.xx
Connecting to myrepo|xx.xxx.xxx.xx|:80... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: http://myrepo/artifactory/repos/x/SNAPSHOT/maven-metadata.xml/ [following]
--2015-12-11 11:17:18--  http://myrepo/artifactory/repos/x/SNAPSHOT/maven-metadata.xml/
Reusing existing connection to myrepo:80.
HTTP request sent, awaiting response... 404 Not Found
2015-12-11 11:17:18 ERROR 404: Not Found.

Artifactory is just returning 302 moved temporarily to the same URL with a slash added like a directory notation. Any idea why accessing virtual repository is not possible this way? In consequence, my Gradle build cannot resolve this dependency.

1
Note that I can reproduce the odd behavior with a local repository that has only release artifacts (snapshots not allowed).Steffen Harbich
Which beats the statement you made in the original question "when I try to get the artifact directly, it works fine". Please clarify the question.JBaruch
I don't see any contradiction. When i can access the local repository directly then it should be possible to access the artifact through the virtual repository that contains the local one.Steffen Harbich
You just said that you can reproduce it with local repository, which means it's not a problem with virtual.JBaruch
That's a great feature request. Passing it on. Thanks, @guaiJBaruch

1 Answers

7
votes

The root cause of this issue is the remote repository pointing at http://mirrors.ibiblio.org/pub/mirrors/maven2.
All requests to this repository will be redirected to http://maven.ibiblio.org/maven2/ no matter which path you are using and more important whether the requested resource exists.
The result is that when requesting an artifact from the virtual repository, at a certain point Artifactory will try to fetch the artifact from this remote repository and will get a 302 answer which redirects to the root of the repository. Artifactory assumes it got the resource it was looking for (got a 200 response code), however the returned resource is a folder and hence the additional / at the end of the URL.

The best solution would be just removing this remote repository and relying on JCenter.
If you do need it, use the http://maven.ibiblio.org/maven2/ URL which will save the redirects.