본문 바로가기

프레임워크

mvn deploy:deploy-file에서 Return Code 401 이 발생했을 때 원인과 처리방법

아래와 같이 메이븐을 실행하고 난후 "Return Code 401"과 같은 에러가 발생했다.
에러를 처리하기위해 여러 구글링을 했지만 역시 특별한 해결책은 없어 보였다.
대부분 settings.xml에서

<servers>
  <server>
   <id>nextech-rep</id>
   <username>dev</username>
   <password>dev</password>
  </server>
 </servers>

와 같이 설정했는데 이 사용자의 권한이 없는 것이란다. 흠. 그래서 권한이 있는 유저로 바꿔도 같은 에러만 반복되었다.

아뿔싸. -DrepositoryId=centeral 와 같이 나는 repositoryId를 repositories/repository 의 id로 착각하여 centeral과 같이 준것이다.

http://www.jfrog.org/sites/artifactory/1.2/import.html
에 다음과 같은 글이 나를 구원해 줬다.

NOTE: the repositoryId my-artifactory should be a server id declared in maven settings.xml. You will get a 401 error if there is no valid username/password provided for deploying to Artifactory.

정말 이 한줄때문에 ~~~
결국 해결책은 -DrepositoryId=nextech-rep 와 같이 해주는 것이다. 물론 권한이 있는 유저이어야만 한다.

D:\uResort\workspace2\UResortFoWEB>mvn deploy:deploy-file -DgroupId=kr.seohak.uresort.WebLib -DartifactId=xFormsXmlSaxLib -Dversion=1.0 -Dpackaging=jar -Dfile=D:\uResort\workspace2\UResortFoWEB\WebContent\WEB-INF\lib\xFormsXmlSaxLib.jar -Durl=http://192.168.10.200:8081/artifactory/libs-releases -DrepositoryId=centeral -e

+ Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'deploy'.
WAGON_VERSION: 1.0-beta-2
[INFO] ----------------------------------------------------------------------------
[INFO] Building UResort FO Web
[INFO]    task-segment: [deploy:deploy-file] (aggregator-style)
[INFO] ----------------------------------------------------------------------------
[INFO] [deploy:deploy-file]
Uploading: http://192.168.10.200:8081/artifactory/libs-releases/kr/seohak/uresort/WebLib/xFormsXmlSaxLib/1.0/xFormsXmlSaxLib-1.0.jar
172K uploaded
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error deploying artifact: Failed to transfer file: http://192.168.10.200:8081/artifactory/libs-releases/kr/seohak/uresort/WebLib/xFormsXmlSaxLib/1.0/xFormsXmlSaxLib-1.0.jar. Return code is: 401

[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: Error deploying artifact: Failed to transfer file: http://192.168.10.200:8081/artifactory/libs-releases/kr/seohak/uresort/WebLib/xFormsXmlSaxLib/1.0/xFormsXmlSaxLib-1.0.jar. Return code is: 401
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:564)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:493)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:463)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:311)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:224)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:143)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:334)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:125)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:280)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
        at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.MojoExecutionException: Error deploying artifact: Failed to transfer file: http://192.168.10.200:8081/artifactory/libs-releases/kr/seohak/uresort/WebLib/xFormsXmlSaxLib/1.0/xFormsXmlSaxLib-1.0.jar. Return code is: 401
        at org.apache.maven.plugin.deploy.DeployFileMojo.execute(DeployFileMojo.java:243)
        at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:443)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:539)
        ... 16 more
Caused by: org.apache.maven.artifact.deployer.ArtifactDeploymentException: Error deploying artifact: Failed to transfer file: http://192.168.10.200:8081/artifactory/libs-releases/kr/seohak/uresort/WebLib/xFormsXmlSaxLib/1.0/xFormsXmlSaxLib-1.0.jar. Return code is: 401
        at org.apache.maven.artifact.deployer.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:94)
        at org.apache.maven.plugin.deploy.DeployFileMojo.execute(DeployFileMojo.java:239)
        ... 18 more
Caused by: org.apache.maven.wagon.TransferFailedException: Failed to transfer file: http://192.168.10.200:8081/artifactory/libs-releases/kr/seohak/uresort/WebLib/xFormsXmlSaxLib/1.0/xFormsXmlSaxLib-1.0.jar. Return code is: 401
        at org.apache.maven.wagon.providers.http.LightweightHttpWagon.put(LightweightHttpWagon.java:172)
        at org.apache.maven.artifact.manager.DefaultWagonManager.putRemoteFile(DefaultWagonManager.java:237)
        at org.apache.maven.artifact.manager.DefaultWagonManager.putArtifact(DefaultWagonManager.java:153)
        at org.apache.maven.artifact.deployer.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:80)
        ... 19 more
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 second
[INFO] Finished at: Tue Jun 03 19:27:51 KST 2008
[INFO] Final Memory: 3M/6M
[INFO] ------------------------------------------------------------------------