ArtifactDescriptorException的解決方法

瓜瓜東西發表於2014-09-26

最近在切換Maven Repository路徑時,eclipse中遇到了ArtifactDescriptorException的問題,而且一下就是400多個error。


ArtifactDescriptorException的解決方法 - 高飛航 - 高飛航的部落格
 
該錯誤的詳細描述如下:

ArtifactDescriptorException: Failed to read artifact descriptor for woodstox:wstx-asl:jar:3.2.7: ArtifactResolutionException: Failure to transfer woodstox:wstx-asl:pom:3.2.7 from https://repository.cloudera.com/content/repositories/snapshots was cached in the local repository, resolution will not be reattempted until the update interval of cdh.snapshot.repo has elapsed or updates are forced. Original error: Could not transfer artifact woodstox:wstx-asl:pom:3.2.7 from/to cdh.snapshot.repo (https://repository.cloudera.com/content/repositories/snapshots): Failed to transfer https://repository.cloudera.com/content/repositories/snapshots/woodstox/wstx-asl/3.2.7/wstx-asl-3.2.7.pom. Error code 409, The repository 'libs-snapshot-local' rejected the artifact 'libs-snapshot-local:woodstox/wstx-asl/3.2.7/wstx-asl-3.2.7.pom' due to its snapshot/release handling policy.

看上去是有什麼東西無法下載,但工程各種Clean、重新匯入、Update Dependency、package、eclipse:eclipse都無效,切換到老的Repository就沒問題。去新的路徑下看,對應的jar包也都在,又懷疑pom中有格式錯誤,各種調整也沒有解決。

後來執行 mvn dependency:tree 時,發現這樣一段資訊:

[WARNING] POM for 'com.taobao.promotioncenter:promotion-common-client:pom:2.2.0:compile' is invalid. Its dependencies (if any) will NOT be available to the current build. Downloading: http://mvnrepo.taobao.ali.com/mvn/repository/woodstox/wstx-asl/3.2.7/wstx-asl-3.2.7.pom [INFO] Unable to find resource 'woodstox:wstx-asl:pom:3.2.7' in repository central (http://mvnrepo.taobao.ali.com/mvn/repository) Downloading: https://repository.cloudera.com/content/repositories/snapshots/woodstox/wstx-asl/3.2.7/wstx-asl-3.2.7.pom [WARNING] Unable to get resource 'woodstox:wstx-asl:pom:3.2.7' from repository cdh.snapshot.repo (https://repository.cloudera.com/content/repositories/snapshots): Error transferring file: Server returned HTTP response code: 502 for URL: https://repository.cloudera.com/content/repositories/snapshots/woodstox/wstx-asl/3.2.7/wstx-asl-3.2.7.pom Downloading: https://repository.cloudera.com/content/groups/cloudera-repos/woodstox/wstx-asl/3.2.7/wstx-asl-3.2.7.pom [WARNING] Unable to get resource 'woodstox:wstx-asl:pom:3.2.7' from repository cdh.repo (https://repository.cloudera.com/content/groups/cloudera-repos): Error transferring file: Server returned HTTP response code: 502 for URL: https://repository.cloudera.com/content/groups/cloudera-repos/woodstox/wstx-asl/3.2.7/wstx-asl-3.2.7.pom Downloading: http://people.apache.org/~rawson/repo//woodstox/wstx-asl/3.2.7/wstx-asl-3.2.7.pom [INFO] Unable to find resource 'woodstox:wstx-asl:pom:3.2.7' in repository temp-thrift (http://people.apache.org/~rawson/repo/) Downloading: http://mvnrepo.taobao.ali.com/mvn/repository/woodstox/wstx-asl/3.2.7/wstx-asl-3.2.7.pom [INFO] Unable to find resource 'woodstox:wstx-asl:pom:3.2.7' in repository java.net (http://download.java.net/maven/2/) Downloading: http://repository.codehaus.org//woodstox/wstx-asl/3.2.7/wstx-asl-3.2.7.pom [INFO] Unable to find resource 'woodstox:wstx-asl:pom:3.2.7' in repository codehaus (http://repository.codehaus.org/) [WARNING] POM for 'com.taobao.hsf:hsf.services:pom:1.4:compile' is invalid.

可以看出,Maven嘗試了各種下載地址仍沒有成功下載這個jar包的資訊,於是更傾向於無法下載的原因。

看了一下這個jar包的引用關係,是一個間接引用的非必需jar包,將其exclude掉後400多個error立即消失。

總結:
1. 該問題還是由於某個jar包相關的資訊無法下載,導致Maven無法正確讀取其pom中的資訊,因此是ArtifactDescriptorException。
2. 其他400多個error是由於這一個問題jar包導致,可以隨之一起修復。
3. 像這種實在無法下載的情況,最好的方式就是將其exclude掉。如果是必需的jar包,暫時不知道有什麼好的方法。但必需的應該是很常用的jar包,不會出現這種無法下載的情況。

<原創文章,轉載請註明出處>

相關文章