简体   繁体   English

Maven 3.5.2无法将工件部署到Artifactory,错误417

[英]Maven 3.5.2 cannot deploy artifact to Artifactory with error 417

I'm creating the simple pom project as the following:- 我正在创建简单的pom项目如下: -

<project xmlns="http://maven.apache.org/POM/4.0.0"
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
                        http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.test</groupId>
    <artifactId>test-maven</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>pom</packaging>
    <name>test-maven</name>
    <distributionManagement>
        <repository>
            <id>central</id>
            <name>myartifactory</name>
            <url>
               https://myhost/artifactory/libs-release-local
            </url>
        </repository>
        <snapshotRepository>
            <id>snapshots</id>
            <name>myartifactory</name>
            <url>
               https://myhost/artifactory/libs-snapshot-local
            </url>
        </snapshotRepository>
    </distributionManagement>
    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-deploy-plugin</artifactId>
                    <version>2.8.2</version>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
</project>

The settings.xml is settings.xml

<servers>
    <server>
        <id>central</id>
        <username>my-user-id</username>
        <password>some-encrypyted-password</password>
    </server>
    <server>
        <id>snapshots</id>
        <username>my-user-id</username>
        <password>some-encrypyted-password</password>
    </server>
</servers>

This project is able to be deployed to Artifactory 5.8.3 by using Maven 3.3.9 : mvn clean deploy . 通过使用Maven 3.3.9mvn clean deploy ,可以将此项目部署到Artifactory 5.8.3

Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T23:41:47+07:00)
Maven home: C:\Java.Application\Apache\apache-maven-3.3.9\bin\..
Java version: 1.8.0_121, vendor: Oracle Corporation
Java home: C:\Java.Application\Sun\Java\jdk1.8.0_121\jre
Default locale: en_US, platform encoding: UTF-8
OS name: "windows 10", version: "10.0", arch: "amd64", family: "dos"

But when I change to Maven 3.5.2 但是当我改为Maven 3.5.2

Apache Maven 3.5.2 (138edd61fd100ec658bfa2d307c43b76940a5d7d; 2017-10-18T14:58:13+07:00)
Maven home: C:\Java.Application\Apache\apache-maven-3.5.2\bin\..
Java version: 1.8.0_121, vendor: Oracle Corporation
Java home: C:\Java.Application\Sun\Java\jdk1.8.0_121\jre
Default locale: en_US, platform encoding: UTF-8
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

During the executing the mvn clean deploy there is an error as 在执行mvn clean deploy出现错误

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy 
(default-deploy) on project test-maven: Failed to deploy artifacts: 
Could not transfer artifact com.test:test-maven:pom:0.0.1-20180213.064245-2 from/to 
snapshots (https://myhost/artifactory/libs-snapshot-local): Failed to transfer file: 
https://myhost/artifactory/libs-snapshot-local/com/test/test-maven/
0.0.1-SNAPSHOT/test-maven-0.0.1-20180213.064245-2.pom. 
Return code is: 417, ReasonPhrase: Expectation Failed. -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: 
    Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy 
    (default-deploy) on project test-maven: 
    Failed to deploy artifacts: Could not transfer artifact...
    .../0.0.1-SNAPSHOT/test-maven-0.0.1-20180213.064245-2.pom. 
    Return code is: 417, ReasonPhrase: Expectation Failed.
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:213)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)

Am I doing something wrong? 难道我做错了什么? Could you please help to advise? 你能帮忙建议吗?

EDIT 1 编辑1

  1. There is no any log printing at artifactory.log at that time. 那时artifactory.log上没有任何日志打印。

  2. The request.log request.log

20180213162947|1|REQUEST|some-ip|non_authenticated_user|GET|/libs-snapshot-local/com/test/test-maven/0.0.1-SNAPSHOT/maven-metadata.xml|HTTP/1.0|401|0
20180213162947|193|REQUEST|some-ip|my-user|GET|/libs-snapshot-local/com/test/test-maven/0.0.1-SNAPSHOT/maven-metadata.xml|HTTP/1.0|200|605
20180213162947|3|REQUEST|some-ip|my-user|GET|/libs-snapshot-local/com/test/test-maven/0.0.1-SNAPSHOT/maven-metadata.xml.sha1|HTTP/1.0|200|40
  1. The access.log access.log
2018-02-13 16:29:47,347 [ACCEPTED DOWNLOAD] libs-snapshot-local:com/test/test-maven/0.0.1-SNAPSHOT/maven-metadata.xml for my-user/some-ip.
2018-02-13 16:29:47,437 [ACCEPTED DOWNLOAD] libs-snapshot-local:com/test/test-maven/0.0.1-SNAPSHOT/maven-metadata.xml.sha1 for my-user/some-ip.

EDIT 2 编辑2

The mvn clean deploy -e -X log mvn clean deploy -e -X log

[INFO] 
[INFO] --- maven-deploy-plugin:2.8.2:deploy (default-deploy) @ test-maven ---
[DEBUG] Dependency collection stats: {ConflictMarker.analyzeTime=129185, ConflictMarker.markTime=69136, ConflictMarker.nodeCount=36, ConflictIdSorter.graphTime=58074, ConflictIdSorter.topsortTime=20149, ConflictIdSorter.conflictIdCount=16, ConflictIdSorter.conflictIdCycleCount=0, ConflictResolver.totalTime=960001, ConflictResolver.conflictItemCount=36, DefaultDependencyCollector.collectTime=76597424, DefaultDependencyCollector.transformTime=1258668}
[DEBUG] org.apache.maven.plugins:maven-deploy-plugin:jar:2.8.2:
[DEBUG]    org.apache.maven:maven-plugin-api:jar:2.2.1:compile
[DEBUG]    org.apache.maven:maven-project:jar:2.2.1:compile
[DEBUG]       org.apache.maven:maven-settings:jar:2.2.1:compile
[DEBUG]       org.apache.maven:maven-profile:jar:2.2.1:compile
[DEBUG]       org.apache.maven:maven-artifact-manager:jar:2.2.1:compile
[DEBUG]          org.apache.maven:maven-repository-metadata:jar:2.2.1:compile
[DEBUG]          backport-util-concurrent:backport-util-concurrent:jar:3.1:compile
[DEBUG]       org.apache.maven:maven-plugin-registry:jar:2.2.1:compile
[DEBUG]       org.codehaus.plexus:plexus-interpolation:jar:1.11:compile
[DEBUG]       org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-9-stable-1:compile
[DEBUG]          junit:junit:jar:3.8.1:compile
[DEBUG]          classworlds:classworlds:jar:1.1-alpha-2:compile
[DEBUG]    org.apache.maven:maven-model:jar:2.2.1:compile
[DEBUG]    org.apache.maven:maven-artifact:jar:2.2.1:compile
[DEBUG]    org.codehaus.plexus:plexus-utils:jar:3.0.15:compile
[DEBUG] Created new class realm plugin>org.apache.maven.plugins:maven-deploy-plugin:2.8.2
[DEBUG] Importing foreign packages into class realm plugin>org.apache.maven.plugins:maven-deploy-plugin:2.8.2
[DEBUG]   Imported:  < maven.api
[DEBUG] Populating class realm plugin>org.apache.maven.plugins:maven-deploy-plugin:2.8.2
[DEBUG]   Included: org.apache.maven.plugins:maven-deploy-plugin:jar:2.8.2
[DEBUG]   Included: backport-util-concurrent:backport-util-concurrent:jar:3.1
[DEBUG]   Included: org.codehaus.plexus:plexus-interpolation:jar:1.11
[DEBUG]   Included: junit:junit:jar:3.8.1
[DEBUG]   Included: org.codehaus.plexus:plexus-utils:jar:3.0.15
[DEBUG] Configuring mojo org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy from plugin realm ClassRealm[plugin>org.apache.maven.plugins:maven-deploy-plugin:2.8.2, parent: sun.misc.Launcher$AppClassLoader@55f96302]
[DEBUG] Configuring mojo 'org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy' with basic configurator -->
[DEBUG]   (f) artifact = com.test:test-maven:pom:0.0.1-SNAPSHOT
[DEBUG]   (f) attachedArtifacts = []
[DEBUG]   (f) deployAtEnd = false
[DEBUG]   (s) localRepository =       id: local
      url: file:///D:/M2/Repository/
   layout: default
snapshots: [enabled => true, update => always]
 releases: [enabled => true, update => always]

[DEBUG]   (f) offline = false
[DEBUG]   (f) packaging = pom
[DEBUG]   (f) pomFile = D:\JavaPrj\sample\test-maven\pom.xml
[DEBUG]   (f) project = MavenProject: com.test:test-maven:0.0.1-SNAPSHOT @ D:\JavaPrj\sample\test-maven\pom.xml
[DEBUG]   (f) reactorProjects = [MavenProject: com.test:test-maven:0.0.1-SNAPSHOT @ D:\JavaPrj\sample\test-maven\pom.xml]
[DEBUG]   (f) retryFailedDeploymentCount = 1
[DEBUG]   (f) skip = false
[DEBUG]   (f) updateReleaseInfo = false
[DEBUG] -- end configuration --
[DEBUG] Using transporter WagonTransporter with priority -1.0 for https://myhost/artifactory/libs-snapshot-local
[DEBUG] Using connector BasicRepositoryConnector with priority 0.0 for https://myhost/artifactory/libs-snapshot-local with username=my-user, password=***
Downloading from snapshots: https://myhost/artifactory/libs-snapshot-local/com/test/test-maven/0.0.1-SNAPSHOT/maven-metadata.xml
Progress (1): maven-metadata.xml (605 B)

Downloaded from snapshots: https://myhost/artifactory/libs-snapshot-local/com/test/test-maven/0.0.1-SNAPSHOT/maven-metadata.xml (605 B at 961 B/s)
[DEBUG] Writing tracking file D:\M2\Repository\com\test\test-maven\0.0.1-SNAPSHOT\resolver-status.properties
Uploading to snapshots: https://myhost/artifactory/libs-snapshot-local/com/test/test-maven/0.0.1-SNAPSHOT/test-maven-0.0.1-20180213.092946-2.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.018 s
[INFO] Finished at: 2018-02-13T16:29:46+07:00
[INFO] Final Memory: 11M/162M
[INFO] ------------------------------------------------------------------------

EDIT 3 编辑3

Add the Apache httpd access_log . 添加Apache httpd access_log

my-ip - - [13/Feb/2018:17:40:48 +0700] "GET /artifactory/libs-snapshot-local/com/test/test-maven/0.0.1-SNAPSHOT/maven-metadata.xml HTTP/1.1" 401 91
my-ip - - [13/Feb/2018:17:40:48 +0700] "GET /artifactory/libs-snapshot-local/com/test/test-maven/0.0.1-SNAPSHOT/maven-metadata.xml HTTP/1.1" 200 605
my-ip - - [13/Feb/2018:17:40:48 +0700] "GET /artifactory/libs-snapshot-local/com/test/test-maven/0.0.1-SNAPSHOT/maven-metadata.xml.sha1 HTTP/1.1" 200 40
my-ip - - [13/Feb/2018:17:40:48 +0700] "PUT /artifactory/libs-snapshot-local/com/test/test-maven/0.0.1-SNAPSHOT/test-maven-0.0.1-20180213.104048-2.pom HTTP/1.1" 417 364

EDIT 4 编辑4

Regarding to the Configuring a Reverse Proxy , this generating is not available for the Artifactory OSS version. 关于配置反向代理 ,此生成不适用于Artifactory OSS版本。

  1. Here is my Apache httpd setting. 这是我的Apache httpd设置。
<Location /artifactory/>

  ProxyPass https://myhost:62443/artifactory/
  ProxyPassReverse https://myhost/artifactory/
  SetEnv force-proxy-request-1.0 1
  SetEnv proxy-nokeepalive 1
</Location>
  1. The artifactory/tomcat/conf/server.xml artifactory/tomcat/conf/server.xml
<Server port="8015" shutdown="SHUTDOWN">

    <Service name="Catalina">
        <!--Connector port="8081" sendReasonPhrase="true"/-->
        <!-- Define a SSL Coyote HTTP/1.1 Connector on port 8443 -->
        <Connector
           protocol="org.apache.coyote.http11.Http11NioProtocol"
           port="62443" maxThreads="200" URIEncoding="UTF-8" 
           scheme="https" secure="true" SSLEnabled="true"
           keystoreFile="/path/to/jks" keystorePass="some-password"
           clientAuth="false" sslProtocol="TLS"/>

        <!-- Must be at least the value of artifactory.access.client.max.connections -->
        <Connector port="8040" sendReasonPhrase="true" maxThreads="50"/>

        <!-- This is the optional AJP connector -->
        <Connector port="8019" protocol="AJP/1.3" sendReasonPhrase="true"/>

        <Engine name="Catalina" defaultHost="localhost">
            <Host name="localhost" appBase="webapps" startStopThreads="2"/>
        </Engine>
    </Service>

</Server>

EDIT 5 编辑5

I would like to highlight some significant as the following: - 我想强调一些重要的内容如下: -

  1. By using the Maven 3.3.9 to deploy this project against the existing Artifactory with Apache httpd is worked properly. 通过使用Maven 3.3.9针对现有Artifactory部署此项目, Apache httpd工作正常。 Please correct me if I'm wrong. 如果我错了,请纠正我。 I understand that there is no any issue about the configuration. 我知道配置没有任何问题。

  2. The only changing is the Maven 3.5.2 . 唯一的变化是Maven 3.5.2

I've no any clue why this issue occur. 我不知道为什么会出现这个问题。

EDIT 6 编辑6

Since there is an exception about the wagon 因为有一个关于wagon的例外

Caused by: org.apache.maven.wagon.TransferFailedException: 
Failed to transfer file: https://myhost/artifactory/libs-snapshot-local/com/test/test-maven/0.0.1-SNAPSHOT/test-maven-0.0.1-20180214.065633-7.pom. Return code is: 417, ReasonPhrase: Expectation Failed.
    at org.apache.maven.wagon.shared.http.AbstractHttpClientWagon.put (AbstractHttpClientWagon.java:635)
    at org.apache.maven.wagon.shared.http.AbstractHttpClientWagon.put (AbstractHttpClientWagon.java:557)
    at org.apache.maven.wagon.shared.http.AbstractHttpClientWagon.put (AbstractHttpClientWagon.java:539)
    at org.apache.maven.wagon.shared.http.AbstractHttpClientWagon.put (AbstractHttpClientWagon.java:533)
    at org.apache.maven.wagon.shared.http.AbstractHttpClientWagon.put (AbstractHttpClientWagon.java:513)

I've compared the wagon from maven_home/lib between Maven 3.3.9 and 3.5.2 , and found that the 3.3.9 use wagon version 2.10 and 3.5.2 use wagon 2.12 . 我比较了Maven 3.3.93.5.2之间来自maven_home/libwagon ,并发现3.3.9使用wagon version 2.103.5.2使用wagon 2.12

Try 1 试试1

I copy the maven_home/lib from Maven 3.3.9 to Maven 3.5.2 , the mvn clean deploy works properly. 我将maven_home/lib从Maven 3.3.9复制到Maven 3.5.2mvn clean deploy正常工作。

Try 2 试试2

Copy maven_home/lib from Maven 3.5.2 to Maven 3.3.9 , the same exception occurs. maven_home/lib从Maven 3.5.2复制到Maven 3.3.9 ,发生同样的异常。

Try 3 试试3

I'm updating the pom to use the latest wagon 3.0.0 as the following: - 我正在更新pom以使用最新的wagon 3.0.0如下: -

<properties>
    <my.wagon.vesion>3.0.0</my.wagon.vesion>
</properties>
<build>
    <extensions>
        <extension>
            <groupId>org.apache.maven.wagon</groupId>
            <artifactId>wagon-file</artifactId>
            <version>${my.wagon.vesion}</version>
        </extension>
        <extension>
            <groupId>org.apache.maven.wagon</groupId>
            <artifactId>wagon-http-shared</artifactId>
            <version>${my.wagon.vesion}</version>
        </extension>
        <extension>
            <groupId>org.apache.maven.wagon</groupId>
            <artifactId>wagon-http</artifactId>
            <version>${my.wagon.vesion}</version>
        </extension>
        <extension>
            <groupId>org.apache.maven.wagon</groupId>
            <artifactId>wagon-provider-api</artifactId>
            <version>${my.wagon.vesion}</version>
        </extension>
    </extensions>
</build>

Luckily when I execute mvn clean deploy -e -X against the wagon 3.0.0 there is a HTTP header/request/response printing so that I've found the response as 幸运的是,当我对wagon 3.0.0执行mvn clean deploy -e -X时,有一个HTTP header/request/response打印,所以我发现响应为

[DEBUG] http-outgoing-0 << "<h1>Expectation Failed</h1>[\n]"
[DEBUG] http-outgoing-0 << "<p>The expectation given in the Expect request-header[\n]"
[DEBUG] http-outgoing-0 << "field could not be met by this server.[\n]"
[DEBUG] http-outgoing-0 << "The client sent<pre>[\n]"
[DEBUG] http-outgoing-0 << "    Expect: 100-continue[\n]"
[DEBUG] http-outgoing-0 << "</pre>[\n]"
[DEBUG] http-outgoing-0 << "</p><p>Only the 100-continue expectation is supported.</p>[\n]"
[DEBUG] http-outgoing-0 << "</body></html>[\n]"
[DEBUG] http-outgoing-0 << HTTP/1.1 417 Expectation Failed

Then I google the term Only the 100-continue expectation is supported. 然后我谷歌术语Only the 100-continue expectation is supported. and found some significant from StackOverflow: Apache and mod_proxy not handling HTTP 100-continue from client HTTP 417 . 并发现StackOverflow的一些重要内容: Apache和mod_proxy不处理来自客户端HTTP 417的HTTP 100-continue

Try 4 试试4

I've set the httpd.conf as mentioning from the thread above. 我将httpd.conf设置为从上面的线程中提到。

<IfModule mod_headers.c>
    RequestHeader unset Expect early
</IfModule>

At the moment I can execute the mvn clean deploy by using the Maven 3.5.2 properly. 目前我可以通过正确使用Maven 3.5.2来执行mvn clean deploy

Since the root cause is 因为根本原因是

[DEBUG] http-outgoing-0 << "<h1>Expectation Failed</h1>[\n]"
[DEBUG] http-outgoing-0 << "<p>The expectation given in the Expect request-header[\n]"
[DEBUG] http-outgoing-0 << "field could not be met by this server.[\n]"
[DEBUG] http-outgoing-0 << "The client sent<pre>[\n]"
[DEBUG] http-outgoing-0 << "    Expect: 100-continue[\n]"
[DEBUG] http-outgoing-0 << "</pre>[\n]"
[DEBUG] http-outgoing-0 << "</p><p>Only the 100-continue expectation is supported.</p>[\n]"
[DEBUG] http-outgoing-0 << "</body></html>[\n]"
[DEBUG] http-outgoing-0 << HTTP/1.1 417 Expectation Failed

The StackOverflow answer advise to remove the Expect header by setting the Apache httpd.conf as StackOverflow应答建议通过将Apache httpd.conf设置为删除Expect标头

<IfModule mod_headers.c>
    RequestHeader unset Expect early
</IfModule>

At the moment I can execute the mvn clean deploy by using the Maven 3.5.2 properly. 目前我可以通过正确使用Maven 3.5.2来执行mvn clean deploy

If you can not fix your current problem, you can try other deployment mechanisms like maven Artifactory plugin or deploying from CI. 如果无法解决当前问题,可以尝试其他部署机制,如maven Artifactory插件或从CI部署。 In one of Artifactory's blog posts it is advised to deploy from Jenkins(or other CI in non-cloud environments) to aquire cleaner pom.xml's. 在Artifactory的一篇博客文章中,建议从Jenkins(或非云环境中的其他CI)部署到获取更清洁的pom.xml。 https://www.jfrog.com/confluence/display/RTF/Maven+Artifactory+Plugin https://jfrog.com/blog/dont-let-maven-deploy-plugin-trip-you/ https://www.jfrog.com/confluence/display/RTF/Maven+Artifactory+Plugin https://jfrog.com/blog/dont-let-maven-deploy-plugin-trip-you/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM