Why am I getting a “401 Unauthorized” error in Maven?

前端 未结 21 1845
栀梦
栀梦 2020-11-29 18:06

Why am I getting a \"401 Unauthorized\" error in Maven?

Here\'s the error I\'m getting when calling mvn deploy (full logs at the bottom):

21条回答
  •  天涯浪人
    2020-11-29 18:38

    As stated in @John's answer, the fact that there is already a 0.1.2-SNAPSHOT, interfered with my new non-SNAPSHOT version 0.1.2. Since the 401 Unauthorized error is nebulous and unhelpful--and is normally associated to user/pass problems--it's no surprise that I was unable to figure this out on my own.

    Changing the version to 0.1.3 brings me back to my original error:

    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.4:install (default-install) on project xbnjava: Failed to install artifact com.github.aliteralmind:xbnjava:jar:0.1.3: R:\jeffy\programming\build\xbnjava-0.1.3\download\xbnjava-0.1.3-all.jar (The system cannot find the path specified) -> [Help 1].

    A sonatype support person also recommended that I remove the block from my POM (it's only there because it's in the one from ez-vcard, which is what I started with) and replace my block with

    
      
        ossrh
        https://oss.sonatype.org/content/repositories/snapshots
      
      
        ossrh
        https://oss.sonatype.org/service/local/staging/deploy/maven2/
      
    
    and then make sure that lines up with what's in your settings.xml:
    
      
        
          ossrh
          your-jira-id
          your-jira-pwd
        
      
    
    

    After doing this, running mvn deploy actually uploaded one of my jars for the very first time!!!

    Output:

    [INFO] Scanning for projects...
    [INFO]
    [INFO] ------------------------------------------------------------------------
    [INFO] Building XBN-Java 0.1.3
    [INFO] ------------------------------------------------------------------------
    [INFO]
    [INFO] --- build-helper-maven-plugin:1.8:attach-artifact (attach-artifacts) @ xbnjava ---
    [INFO]
    [INFO] --- maven-install-plugin:2.4:install (default-install) @ xbnjava ---
    [INFO] Installing R:\jeffy\programming\sandbox\z__for_git_commit_only\xbnjava\pom.xml to C:\Users\jeffy\.m2\repository\com\github\aliteralmind\xbnjava\0.1.3\xbnjava-0.1.3.pom
    [INFO] Installing R:\jeffy\programming\build\xbnjava-0.1.3\download\xbnjava-0.1.3.jar to C:\Users\jeffy\.m2\repository\com\github\aliteralmind\xbnjava\0.1.3\xbnjava-0.1.3.jar
    [INFO]
    [INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) @ xbnjava ---
    Uploading: https://oss.sonatype.org/service/local/staging/deploy/maven2/com/github/aliteralmind/xbnjava/0.1.3/xbnjava-0.1.3.pom
    2/6 KB
    4/6 KB
    6/6 KB
    
    Uploaded: https://oss.sonatype.org/service/local/staging/deploy/maven2/com/github/aliteralmind/xbnjava/0.1.3/xbnjava-0.1.3.pom (6 KB at 4.6 KB/sec)
    Downloading: https://oss.sonatype.org/service/local/staging/deploy/maven2/com/github/aliteralmind/xbnjava/maven-metadata.xml
    310/310 B
    
    Downloaded: https://oss.sonatype.org/service/local/staging/deploy/maven2/com/github/aliteralmind/xbnjava/maven-metadata.xml (310 B at 1.6 KB/sec)
    Uploading: https://oss.sonatype.org/service/local/staging/deploy/maven2/com/github/aliteralmind/xbnjava/maven-metadata.xml
    310/310 B
    
    Uploaded: https://oss.sonatype.org/service/local/staging/deploy/maven2/com/github/aliteralmind/xbnjava/maven-metadata.xml (310 B at 1.4 KB/sec)
    Uploading: https://oss.sonatype.org/service/local/staging/deploy/maven2/com/github/aliteralmind/xbnjava/0.1.3/xbnjava-0.1.3.jar
    2/630 KB
    4/630 KB
    6/630 KB
    8/630 KB
    10/630 KB
    12/630 KB
    14/630 KB
    ...
    618/630 KB
    620/630 KB
    622/630 KB
    624/630 KB
    626/630 KB
    628/630 KB
    630/630 KB
    

    (Success portion:)

    Uploaded: https://oss.sonatype.org/service/local/staging/deploy/maven2/com/github/aliteralmind/xbnjava/0.1.3/xbnjava-0.1.3.jar (630 KB at 474.7 KB/sec)
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESS
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 4.632 s
    [INFO] Finished at: 2014-07-18T15:09:25-04:00
    [INFO] Final Memory: 6M/19M
    [INFO] ------------------------------------------------------------------------
    

    Here's the full updated POM:

    
      4.0.0
      com.github.aliteralmind
      xbnjava
      pom
      0.1.3
      XBN-Java
      https://github.com/aliteralmind/xbnjava
      2014
      
         Jeff Epstein
      
      XBN-Java is a collection of generically-useful backend (server side, non-GUI) programming utilities, featuring RegexReplacer and FilteredLineIterator. XBN-Java is the foundation of Codelet (http://codelet.aliteralmind.com).
    
      
         
            Lesser General Public License (LGPL) version 3.0
            https://www.gnu.org/licenses/lgpl-3.0.txt
         
         
            Apache Software License (ASL) version 2.0
            http://www.apache.org/licenses/LICENSE-2.0.txt
         
      
    
      
         
            Jeff Epstein
            aliteralmind-github@yahoo.com
            
               Lead Developer
            
         
      
    
      
         GitHub Issue Tracker
         https://github.com/aliteralmind/xbnjava/issues
      
    
      
        
          ossrh
          https://oss.sonatype.org/content/repositories/snapshots
        
        
          ossrh
          https://oss.sonatype.org/service/local/staging/deploy/maven2/
        
      
    
      
         scm:git:git@github.com:aliteralmind/xbnjava.git
         scm:git:git@github.com:aliteralmind/xbnjava.git
         scm:git:git@github.com:aliteralmind/xbnjava.git
      
    
      
         1.7
         R:\jeffy\programming\build\/${project.artifactId}-${project.version}/download/${project.artifactId}-${project.version}
      
      
         
            
               org.codehaus.mojo
               build-helper-maven-plugin
               1.8
               
                  
                     attach-artifacts
                     package
                     
                        attach-artifact
                     
                     
                        
                           
                              ${jarprefix}.jar
                              jar
                           
                        
                     
                  
               
            
         
      
    
      
         
         
            release-sign-artifacts
            
               
                  release
                  true
               
            
         
      
    
    

    That's one big Maven problem out of the way. Only 627 more to go.

提交回复
热议问题