一、問題背景

代碼已經提交到github,完整代碼請參考:Ttbigdata

在基於 Bigtop 編譯 Apache Knox 2.1.0 的過程中,整體構建已經進入後半段,大量模塊顯示為 SKIPPED,但在處理安全相關模塊時構建突然中斷。

從構建路徑和模塊名稱可以判斷,此階段已經進入 Knox 的 Provider / Security 相關實現,一旦失敗,後續 Knox 組件將全部無法繼續。

這類問題在 Bigtop + 內網 Nexus 的環境下非常常見, 並不屬於代碼問題,而是典型的 第三方 Maven 依賴缺失

二、報錯信息與日誌定位

核心報錯信息如下:

NFO] gateway-service-session 2.1.0 ...................... SKIPPED
[INFO] gateway-release 2.1.0 .............................. SKIPPED
[INFO] gateway-service-vault 2.1.0 ........................ SKIPPED
[INFO] gateway-test-release-utils 2.1.0 ................... SKIPPED
[INFO] gateway-test 2.1.0 ................................. SKIPPED
[INFO] gateway-test-release 2.1.0 ......................... SKIPPED
[INFO] webhdfs-kerb-test 2.1.0 ............................ SKIPPED
[INFO] webhdfs-test 2.1.0 ................................. SKIPPED
[INFO] gateway-shell-release 2.1.0 ........................ SKIPPED
[INFO] gateway-docker 2.1.0 ............................... SKIPPED
[INFO] gateway-release-common 2.1.0 ....................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  12:13 min
[INFO] Finished at: 2025-12-11T02:52:38Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project gateway-provider-security-pac4j: Could not resolve dependencies for project org.apache.knox:gateway-provider-security-pac4j:jar:2.1.0: Could not find artifact net.shibboleth.tool:xmlsectool:jar:2.0.0 in nexus (http://172.20.0.2:8081/repository/maven-public/) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <args> -rf :gateway-provider-security-pac4j
(base) [root@kylin10 knox-2.1.0-RC2]#

同時可以看到構建最終狀態:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  12:13 min
[INFO] Finished at: 2025-12-11T02:52:38Z

從日誌中可以提取幾個關鍵信息點:

項目

內容

失敗模塊

gateway-provider-security-pac4j

缺失依賴

net.shibboleth.tool:xmlsectool:2.0.0

Maven 倉庫

內部 Nexus(maven-public)

錯誤類型

DependencyResolutionException

三、問題根因分析

1. xmlsectool 並不在 Maven Central

xmlsectool 屬於 Shibboleth 項目體系,其官方 Maven 倉庫地址為:

https://build.shibboleth.net/maven/releases/

該依賴 默認不發佈在 Maven Central,因此:

  • 本地 Maven
  • 企業 Nexus
  • Bigtop 默認構建鏈路

都無法自動拉取該依賴

2. 內部 Nexus 未代理 Shibboleth 倉庫

當前構建使用的倉庫為:

http://172.20.0.2:8081/repository/maven-public/

如果該 group 中未包含 shibboleth-releases,那麼 Maven 在解析依賴時必然失敗。

這個問題 和 Knox 版本無關和 Bigtop 無關, 本質是 倉庫覆蓋不完整

四、解決方案

針對 xmlsectool 依賴缺失的問題,本質上只有一個目標:

讓 Maven 能解析到 net.shibboleth.tool:xmlsectool:2.0.0

根據環境不同,可以採用兩種方式。

方案一:通過 Nexus 統一託管 xmlsectool 依賴(推薦)

該方案適用於:

  • 企業內網
  • 多人協作
  • 多次重複編譯 Bigtop / Ambari / Knox
1. 添加 Shibboleth Releases 倉庫

在 Nexus 中新增一個 Maven Proxy Repository

  • Name:shibboleth-releases
  • Remote URL:
https://build.shibboleth.net/maven/releases/

【Knox編譯】xmlsectool 依賴缺失問題解析_knox

2. 加入 maven-public Group

shibboleth-releases 添加到 maven-public 組倉庫中,確保構建時可以被統一解析。

【Knox編譯】xmlsectool 依賴缺失問題解析_運維_02

3. 恢復構建
mvn compile -rf :gateway-provider-security-pac4j

-rf(resume from)是 Bigtop / Knox 編譯中非常常用的參數, 可以避免從頭全量重編。

4. 一鍵腳本方式(推薦)

如果不想手工配置 Nexus,可以直接使用我們整理的一鍵腳本:

https://github.com/TtBigdata/ambari-env/blob/master/scripts/system/after/nexus/setup_mvn_proxy.sh

該腳本會自動補齊:

  • Shibboleth
  • Apache Snapshots
  • 其他常見第三方 Maven 倉庫

【Knox編譯】xmlsectool 依賴缺失問題解析_knox_03

方案二:直接下載並安裝到本地 Maven 倉庫

該方案適用於:

  • 無法修改 Nexus
  • 臨時編譯
  • 單機調試環境
1. 下載 xmlsectool 依賴

官方目錄地址:

https://build.shibboleth.net/maven/releases/net/shibboleth/tool/xmlsectool/

【Knox編譯】xmlsectool 依賴缺失問題解析_knox_04

2. 安裝到本地倉庫
mvn install:install-file \
  -DgroupId=net.shibboleth.tool \
  -DartifactId=xmlsectool \
  -Dversion=2.0.0 \
  -Dpackaging=jar \
  -Dfile=xmlsectool-2.0.0.jar