본문 바로가기
개발/Java

[Maven 에러] maven warning failed to retrieve plugin descriptor -> 해결 openJDK cacert 인증서 문제 [+덤 SSLException]

by Allonsy 2020. 3. 9.
반응형

굉장굉장 험난한 모험을 완주하고 나 같은 괴로움을 겪을 누군가를 위하여 기록을 남긴다

 

오늘 메이븐 프로젝트 clean과 install이 되지 않는 고통을 겪음..

 

아래와 같은 WARNING이 미친듯이 뜨면서 ERROR가 남

 

[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-clean-plugin:2.5: Plugin org.apache.maven.plugins:maven-clean-plugin:2.5  
or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-clean-plugin:jar:2.5 

mvn archetype:generate 

[INFO] Scanning for projects... 
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom 
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-clean-plugin:2.5: Plugin org.apache.maven.plugins:maven-clean-plugin:2.5  
or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-clean-plugin:jar:2.5 
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-install-plugin/2.4/maven-install-plugin-2.4.pom 
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-install-plugin:2.4: Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-install-plugin:jar:2.4 
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-deploy-plugin/2.7/maven-deploy-plugin-2.7.pom 
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-deploy-plugin:2.7: Plugin org.apache.maven.plugins:maven-deploy-plugin:2.7 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-deploy-plugin:jar:2.7 
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-site-plugin/3.3/maven-site-plugin-3.3.pom 
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-site-plugin:3.3: Plugin org.apache.maven.plugins:maven-site-plugin:3.3 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-site-plugin:jar:3.3 
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-antrun-plugin/1.3/maven-antrun-plugin-1.3.pom 
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-antrun-plugin:1.3: Plugin org.apache.maven.plugins:maven-antrun-plugin:1.3 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-antrun-plugin:jar:1.3 
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-assembly-plugin/2.2-beta-5/maven-assembly-plugin-2.2-beta-5.pom 
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-assembly-plugin:2.2-beta-5: Plugin org.apache.maven.plugins:maven-assembly-plugin:2.2-beta-5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-assembly-plugin:jar:2.2-beta-5 
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-dependency-plugin/2.8/maven-dependency-plugin-2.8.pom 
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-dependency-plugin:2.8: Plugin org.apache.maven.plugins:maven-dependency-plugin:2.8 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-dependency-plugin:jar:2.8 
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-release-plugin/2.5.3/maven-release-plugin-2.5.3.pom 
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-release-plugin:2.5.3: Plugin org.apache.maven.plugins:maven-release-plugin:2.5.3 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-release-plugin:jar:2.5.3 
Downloading from central: https://repo.maven.apache.org/maven2/org/codehaus/mojo/maven-metadata.xml 
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-metadata.xml 
[WARNING] Could not transfer metadata org.apache.maven.plugins/maven-metadata.xml from/to central (https://repo.maven.apache.org/maven2): Transfer failed for https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-metadata.xml 
[WARNING] Could not transfer metadata org.codehaus.mojo/maven-metadata.xml from/to central (https://repo.maven.apache.org/maven2): Transfer failed for https://repo.maven.apache.org/maven2/org/codehaus/mojo/maven-metadata.xml 
[WARNING] Failure to transfer org.apache.maven.plugins/maven-metadata.xml from https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer metadata org.apache.maven.plugins/maven-metadata.xml from/to central (https://repo.maven.apache.org/maven2): Transfer failed for https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-metadata.xml 
[WARNING] Failure to transfer org.codehaus.mojo/maven-metadata.xml from https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer metadata org.codehaus.mojo/maven-metadata.xml from/to central (https://repo.maven.apache.org/maven2): Transfer failed for https://repo.maven.apache.org/maven2/org/codehaus/mojo/maven-metadata.xml 
[INFO] ------------------------------------------------------------------------ 
[INFO] ------------------------------------------------------------------------ 
[INFO] Finished at: 2020-03-09T19:31:50+09:00 
[INFO] ------------------------------------------------------------------------ 
[ERROR] No plugin found for prefix 'archetype' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (C:\Users\inok\.m2\repository), central (https://repo.maven.apache.org/maven2)] -> [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/NoPluginFoundForPrefixException

 

해결안 1.
C:\Users\사용자\.m2 경로에서 .m2 파일을 삭제하고 다시 maven install을 해주면 보통 해결됨

 

헌데 아무리 날리고 clean하고 install을 해도 해결이 되지 않았다..

 

혹시나 싶어서 VSCode의 SpringBoot starter를 이용하여 SpringBoot Maven 프로젝트 생성하여 실행

 

이번엔 SSLException..

 

Exception in thread "main" javax.net.ssl.SSLException: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the 
trustAnchors parameter must be non-empty

Exception in thread "main" javax.net.ssl.SSLException: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the 
trustAnchors parameter must be non-empty
        at sun.security.ssl.Alerts.getSSLException(Alerts.java:214)
        at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1958)
        at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1915)
        at sun.security.ssl.SSLSocketImpl.handleException(SSLSocketImpl.java:1898)
        at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1419)
        at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1396)
        at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:563)
        at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185)
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1512)
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1440)
        at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)
        at org.apache.maven.wrapper.DefaultDownloader.downloadInternal(DefaultDownloader.java:90)
        at org.apache.maven.wrapper.DefaultDownloader.download(DefaultDownloader.java:76)
        at org.apache.maven.wrapper.Installer.createDist(Installer.java:72)
        at org.apache.maven.wrapper.WrapperExecutor.execute(WrapperExecutor.java:121)
        at org.apache.maven.wrapper.MavenWrapperMain.main(MavenWrapperMain.java:61)
Caused by: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty    
        at sun.security.validator.PKIXValidator.<init>(PKIXValidator.java:90)
        at sun.security.validator.Validator.getInstance(Validator.java:179)
        at sun.security.ssl.X509TrustManagerImpl.getValidator(X509TrustManagerImpl.java:312)
        at sun.security.ssl.X509TrustManagerImpl.checkTrustedInit(X509TrustManagerImpl.java:171)
        at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:184)
        at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:124)
        at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1508)
        at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:215)
        at sun.security.ssl.Handshaker.processLoop(Handshaker.java:1024)
        at sun.security.ssl.Handshaker.process_record(Handshaker.java:954)
        at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1065)
        at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1384)
        at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1412)
        ... 11 more
Caused by: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
        at java.security.cert.PKIXParameters.setTrustAnchors(PKIXParameters.java:200)
        at java.security.cert.PKIXParameters.<init>(PKIXParameters.java:120)
        at java.security.cert.PKIXBuilderParameters.<init>(PKIXBuilderParameters.java:104)
        at sun.security.validator.PKIXValidator.<init>(PKIXValidator.java:88)
        ... 23 more

 

진짜 열심히 구글링을 해보았다

 

한줄기 빛을 보았는데 그것은 openJDK를 설치했을 때 cacert 인증서가 없을 수 있다는 것..

 

그럴 경우 https에 접속을 하지 못한다고 한다..

 

어쩐지 이상했던게 maven 중에서도 http는 잘 다운로드 되는데 https부터 안되더라...

 

cacert 파일 경로 : JAVA_HOME/jre/lib/security/cacert

 

cacert 파일을 확인해보니 파일은 잘 있었다.. 

 

그렇다면 키 저장소 항목을 확인해보는 수밖에...

 

JAVA_HOME/bin 경로에서 아래 명령어 실행

키 저장소 초기 비밀번호 : changeit

 

./keytool -list -keystore ../jre/lib/security/cacerts

$ ./keytool -list -keystore ../jre/lib/security/cacerts
키 저장소 비밀번호 입력:

키 저장소 유형: JKS
키 저장소 제공자: SUN

키 저장소에 0개의 항목이 포함되어 있습니다.

하하하 저장소가 텅텅인 것을 확인하였다

 

해결방법

다른 JDK를 다운 받아서 그 안에 있는 cacert 파일을 복사 붙여넣기하면 된다고 한다

 

VSCode Configure Java Runtime에 있던 openJDK를 설치해보고 싶었던 찰나에 이 기회에 openJDK 11 다운

설치형 파일이 다운로드 되었고, 설치 후 cacert 파일을 확인했다

 

cacert 파일 경로: jdk-11.0.6.10-hotspot/lib/security/cacert

 

jdk-11.0.3.10-hotspot/bin 경로에서 아래 명령어 실행 - openJDK8과 경로 다르므로 주의

 

./keytool -list -keystore ../lib/security/cacerts

$ ./keytool -list -keystore ../lib/security/cacerts
키 저장소 비밀번호 입력:

키 저장소 유형: JKS
키 저장소 제공자: SUN

키 저장소에 93개의 항목이 포함되어 있습니다.

아래 인증서가 주르르르륵 뜬다

 

이걸 복사해서 비어있던 cacert 붙여넣어주니 maven 다운로드가 잘 된다

 

성공!!

[ 메이븐 오류 날 때 정리 ]

해결방안 1
C:\Users\사용자\.m2 경로에서 .m2 파일을 삭제하고 다시 maven install

해결방안 2
openJDK를 사용중일 경우 cacert 파일을 확인하고 비어있을 경우 정상적인 cacert 파일로 바꿔주기

반응형

댓글