Artifactory returns HTTP 302 when accessing virtual repository URL

允我心安 提交于 2019-12-10 18:57:56

问题


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:


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.



来源:https://stackoverflow.com/questions/34221284/artifactory-returns-http-302-when-accessing-virtual-repository-url

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!