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

时间:2015-09-03 19:03:28

标签: maven proxy windows-server-2012

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

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

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

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

导致此单一构建失败的原因是什么?

如何确定无法从正确的网址下载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请求的标头:

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',
          }

1 个答案:

答案 0 :(得分:1)

找到答案。

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

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

出于某种原因,只有Windows Server 2012无法将父POM的主机视为非代理主机之一。如果有人知道为什么会这样,我很好奇,但问题已经解决了。

相关问题