Maven 无法从代理存储库下载 Artifact ?

标签 maven proxy windows-server-2012

项目的 Maven 构建在一个系统上失败,但在其他系统上失败。

其他系统正确确定父 pom 位于此处:
http://(address)/nexus/service/local/repositories/releases/content/(path/to/parent.pom)

失败的构建会查看每个代理存储库地址,但无法在正确的代理地址或任何其他代理服务器上找到它(请参阅下面的错误输出)。

两个系统都使用相同的 JDK 和 Maven 版本,使用相同的 settings.xml 文件标识适当的代理存储库。它们具有相同的网络物理连接和类似的防火墙等设置。没有第 3 方防病毒软件。关键区别在于发生故障的系统运行的是 Windows Server 2012 而不是 Windows 7 或 8。

什么可能导致这个单一构建失败?

如何确定无法从正确的 URL 下载 POM 的原因? (请注意,可以从 Internet 浏览器访问该 URL;可以轻松地手动下载 POM。)

扩展的 Maven 输出摘录:

INFO] Scanning for projects...
[DEBUG] Using transporter WagonTransporter with priority -1.0 for http://(address)/nexus/content/groups/public
[DEBUG] Using connector BasicRepositoryConnector with priority 0.0 for http://(address)/nexus/content/groups/public via proxy.company.org:80 with username=, password=***
Downloading: http://(address)/nexus/content/groups/public/org/company/subgroup/subgroup-project/0.2.10/subgroup-project-0.2.10.pom

[DEBUG] Writing tracking file C:\m2repo\org\company\subgroup\subgroup-project\0.2.10\subgroup-project-0.2.10.pom.lastUpdated
[DEBUG] Using transporter WagonTransporter with priority -1.0 for http://(address)/nexus/content/groups/external
[DEBUG] Using connector BasicRepositoryConnector with priority 0.0 for http://(address)/nexus/content/groups/external via proxy.company.org:80 with username=, password=***
Downloading: http://(address)/nexus/content/groups/external/org/company/subgroup/subgroup-project/0.2.10/subgroup-project-0.2.10.pom

[DEBUG] Writing tracking file C:\m2repo\org\company\subgroup\subgroup-project\0.2.10\subgroup-project-0.2.10.pom.lastUpdated
[DEBUG] Using transporter WagonTransporter with priority -1.0 for http://(address)/nexus/content/groups/company-subgroup
[DEBUG] Using connector BasicRepositoryConnector with priority 0.0 for http://(address)/nexus/content/groups/company-subgroup via proxy.company.org:80 with username=, password=***
Downloading: http://(address)/nexus/content/groups/company-subgroup/org/company/subgroup/subgroup-project/0.2.10/subgroup-project-0.2.10.pom

[DEBUG] Writing tracking file C:\m2repo\org\company\subgroup\subgroup-project\0.2.10\subgroup-project-0.2.10.pom.lastUpdated
[DEBUG] Using transporter WagonTransporter with priority -1.0 for http://(address)/nexus/content/groups/mirror
[DEBUG] Using connector BasicRepositoryConnector with priority 0.0 for http://(address)/nexus/content/groups/mirror via proxy.company.org:80 with username=, password=***
Downloading: http://(address)/nexus/content/groups/mirror/org/company/subgroup/subgroup-project/0.2.10/subgroup-project-0.2.10.pom

[DEBUG] Writing tracking file C:\m2repo\org\company\subgroup\subgroup-project\0.2.10\subgroup-project-0.2.10.pom.lastUpdated
[DEBUG] Using transporter WagonTransporter with priority -1.0 for http://(address)/nexus/content/groups/proxied-repositories
[DEBUG] Using connector BasicRepositoryConnector with priority 0.0 for http://(address)/nexus/content/groups/proxied-repositories via proxy.company.org:80 with username=, password=***
Downloading: http://(address)/nexus/content/groups/proxied-repositories/org/company/subgroup/subgroup-project/0.2.10/subgroup-project-0.2.10.pom

[DEBUG] Writing tracking file C:\m2repo\org\company\subgroup\subgroup-project\0.2.10\subgroup-project-0.2.10.pom.lastUpdated
[DEBUG] Using transporter WagonTransporter with priority -1.0 for http://(address)/nexus/content/repositories/central
[DEBUG] Using connector BasicRepositoryConnector with priority 0.0 for http://(address)/nexus/content/repositories/central via proxy.company.org:80 with username=, password=***
Downloading: http://(address)/nexus/content/repositories/central/org/company/subgroup/subgroup-project/0.2.10/subgroup-project-0.2.10.pom

[DEBUG] Writing tracking file C:\m2repo\org\company\subgroup\subgroup-project\0.2.10\subgroup-project-0.2.10.pom.lastUpdated
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[FATAL] Non-resolvable parent POM for org.company.subgroup.project_package:project:0.1: Could not transfer artifact org.company.subgroup:subgroup-project:pom:0.2.10 from/to public (http://(address)/nexus/content/groups/public): Access denied to: http://(address)/nexus/content/groups/public/org/company/subgroup/subgroup-project/0.2.10/subgroup-project-0.2.10.pom , ReasonPhrase:Forbidden. and 'parent.relativePath' points at wrong local POM @ line 15, column 13
 @ 
[ERROR] The build could not read 1 project -> [Help 1]
org.apache.maven.project.ProjectBuildingException: Some problems were encountered while processing the POMs:
[FATAL] Non-resolvable parent POM for org.company.subgroup.project_package:project:0.1: Could not transfer artifact org.company.subgroup:subgroup-project:pom:0.2.10 from/to public (http://(address)/nexus/content/groups/public): Access denied to: http://(address)/nexus/content/groups/public/org/company/subgroup/subgroup-project/0.2.10/subgroup-project-0.2.10.pom , ReasonPhrase:Forbidden. and 'parent.relativePath' points at wrong local POM @ line 15, column 13

编辑:

使用 Wireshark,Maven 似乎收到了对其 GET 请求的 403 Forbidden 响应。如果 Maven 外部的相同请求工作正常,为什么 Maven 会收到此响应?

我用来验证 GET 请求的 header :

user_agent = 'Apache-Maven/3.0.3 (Java 1.8.0_51; Windows Server 2012 R2 6.3)'
headers = { 'Accept-Encoding' : 'gzip',
            'Pragma' : 'no-cache',
            'User-Agent' : user_agent,
            'Host' : proxy.company.org',
            'Accept' : 'text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2',
            'Proxy-Connection' : 'keep-alive',
          }

最佳答案

找到了答案。

<proxy> settings.xml 中的设置已定义 <nonProxyHosts>localhost|company.org</nonProxyHosts> .

正确的设置是 <nonProxyHosts>localhost|*.company.org</nonProxyHosts> .

由于某些原因,只有 Windows Server 2012 未能将父 POM 的主机视为非代理主机之一。如果有人知道这可能是为什么,我很好奇,但问题已解决。

关于Maven 无法从代理存储库下载 Artifact ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32383513/

相关文章:

java - Maven SNAPSHOT 被视为 RELEASE

java - 如果 DataProvider 使用单个测试方法的不同数据运行多个测试,则在 TestNG/Maven 报告中获取测试方法名称

java - 使用 Pump 类的 Vert.x 中的简单 TCP 代理 (JAVA)

php - 将站点迁移到新域和服务器后,WordPress 自定义结构永久链接中断

debugging - visual studio 2012 asp.net 4.0 中没有断点

maven - 如何从单个父 pom.xml 构建具有不同版本的插件?

java - 在组装之后但在安装之前对 jar 进行后处理(以获得幂等构建)

c++ - 哪个 Windows API 用于 Windows 安全代理身份验证对话框?

spring - Tomcat 9 Connector如何监听127.0.0.1反向代理到Win。具有私有(private) ServerName 的 Apache 2.4

iis - Microsoft Azure 中的 Windows Server 2012/IIS8 上的客户端证书身份验证收到 HTTP 403.16