tutorial mvn java maven

java - mvn - maven windows



¿Por qué recibo un error "401 no autorizado" en Maven? (14)

¿Por qué recibo un error "401 no autorizado" en Maven?

Este es el error que recibo cuando llamo a mvn deploy (registros completos en la parte inferior):

[INFO] BUILD FAILURE
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project xbnjava: Failed to deploy artifacts: Could not transfer artifact com.github.aliteralmind:xbnjava:pom:0.1.2 from/to sonatype-nexus-staging (https://oss.sonatype.org/service/local/staging/deploy/maven2/): Failed to transfer file: https://oss.sonatype.org/service/local/staging/deploy/maven2/com/github/aliteralmind/xbnjava/0.1.2/xbnjava-0.1.2.pom. Return code is: 401, ReasonPhrase: Unauthorized. -> [Help 1]

De acuerdo con esta página de soporte sonatype :

"Si está recibiendo un 401 es porque maven está enviando credenciales de inicio de sesión incorrectas, o no tiene ninguna credencial".

A continuación se detallan los pasos que he dado, a continuación se muestran mis archivos completos de settings.xml y pom.xml , y debajo están los registros completos de mvn deploy y mvn deploy -e .

Cualquier idea sería apreciada. Estoy golpeando pared tras pared con Maven.

Seguí la lista de verificación de sonatype cuando recibí un error 401:

Lista de verificación elemento 1 . Asegúrese de que su nombre de usuario / contraseña sea correcto iniciando sesión en la interfaz de usuario de Nexus. Si curl está instalado en su máquina, puede intentar desplegar un artefacto con ...

  • Ingresé y salí exitosamente del sitio web sonatype.org, usando el usuario / pase en settings.xml .
  • Intenté usar curl para implementar manualmente un artefacto, con el comando

[C:/]curl -u MY_SONATYPE_DOT_COM_USERNAME:MY_SONATYPE_DOT_COM_PASSWORD https://oss.sonatype.org/content/repositories/snapshots/com/github/aliteralmind/xbnjava/0.1.2-SNAPSHOT/xbnjava-0.1.2-20140716.224928-1.pom --request PUT --data @pom.xml

pero obtuve este error:

Warning: Couldn''t read data from file "pom.xml", this makes an empty POST. curl: (60) SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed More details here: http://curl.haxx.se/docs/sslcerts.html curl performs SSL certificate verification by default, using a "bundle" of Certificate Authority (CA) public keys (CA certs). If the default bundle file isn''t adequate, you can specify an alternate file using the --cacert option. If this HTTPS server uses a certificate signed by a CA represented in the bundle, the certificate verification probably failed due to a problem with the certificate (it might be expired, or the name might not match the domain name in the URL). If you''d like to turn off curl''s verification of the certificate, use the -k (or --insecure) option.

Lo ejecuté de nuevo con la opción -k , y esta vez obtuve solo esto:

Couldn''t read data from file "pom.xml", this makes an empty POST.

Nunca he usado curl antes, así que no sé qué hacer con esta información.

Lista de verificación elemento 2 . Si no hay salida de error, asegúrese de que sus privilegios de usuario estén configurados correctamente en el servidor. Asegúrese de descartar el repositorio que acaba de crear.

No sé qué significa "soltar". Creo que mis privilegios están instalados correctamente, ya que recibí este mensaje de sonatype:

y he colocado estos elementos con éxito en el servidor a través de mvn deploy en los últimos días.

La configuración del proyecto:

Lista de verificación elemento 3 . Asegúrese de haber configurado un servidor en settings.xml y de que el id del servidor sea idéntico al id del repositorio de distribución en pom.xml.

  • En settings.xml , settings / servers / server / id es igual a ossrh
  • En pom.xml , distributionManagement / snapshotRepository / id es igual a ossrh

(Los archivos completos están en la parte inferior)

Lista de verificación elemento 4 . Asegúrese de que su settings.xml esté en el lugar correcto (normalmente es _ ~ / .m2 / settings.xml). Puede verificar esto ejecutando mvn help: effective-settings.

De acuerdo con la referencia de configuración de Maven, settings.xml debe estar en una de dos ubicaciones:

  • La instalación de Maven: $M2_HOME/conf/settings.xml
  • ${user.home}/.m2/settings.xml un usuario: ${user.home}/.m2/settings.xml

Aquí está mi configuración:

  • settings.xml : C:/applications/programming/apache-maven-3.2.2/conf/settings.xml
  • M2_HOME es C:/applications/programming/apache-maven-3.2.2

Salida para mvn help:effective-settings :

[C:/applications/utilities/curl] [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building Maven Stub Project (No POM) 1 [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-help-plugin:2.2:effective-settings (default-cli) @ standalone-pom --- [INFO] Effective user-specific configuration settings: <?xml version="1.0" encoding="UTF-8"?> <!-- ====================================================================== --> <!-- --> <!-- Generated by Maven Help Plugin on 2014-07-18T12:48:19 --> <!-- See: http://maven.apache.org/plugins/maven-help-plugin/ --> <!-- --> <!-- ====================================================================== --> <!-- ====================================================================== --> <!-- --> <!-- Effective Settings for ''jeffy'' on ''kermit-the-frog'' --> <!-- --> <!-- ====================================================================== --> <settings xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:sc hemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd"> <localRepository xmlns="http://maven.apache.org/SETTINGS/1.1.0">C:/Users/jeffy/.m2/repository</localRepository > <servers xmlns="http://maven.apache.org/SETTINGS/1.1.0"> <server> <username>MY_SONATYPE_DOT_COM_USERNAME</username> <password>***</password> <id>ossrh</id> </server> </servers> <pluginGroups xmlns="http://maven.apache.org/SETTINGS/1.1.0"> <pluginGroup>org.apache.maven.plugins</pluginGroup> <pluginGroup>org.codehaus.mojo</pluginGroup> </pluginGroups> </settings> [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 2.310 s [INFO] Finished at: 2014-07-18T12:48:19-04:00 [INFO] Final Memory: 7M/17M [INFO] ------------------------------------------------------------------------

Lista de verificación elemento 5 . Si el servidor usa https pero la URL en su POM es http, también puede obtener 401.

No entiendo a qué URL se está refiriendo.

Lista de verificación elemento 6 . Utilice la última versión de Maven, ya que existe un problema conocido con respecto a 401: MNG-4469

Estoy usando la última versión:

[C:/]mvn -version Apache Maven 3.2.2 (45f7c06d68e745d05611f7fd14efb6594181933e; 2014-06-17T09:51:42-04:00) Maven home: C:/applications/programming/apache-maven-3.2.2 Java version: 1.7.0_51, vendor: Oracle Corporation Java home: C:/applications/programming/jdk_7_51/jre Default locale: en_US, platform encoding: Cp1252 OS name: "windows 7", version: "6.1", arch: "x86", family: "windows"

------------------

Archivos completos de settings.xml y pom.xml

( mvn deploy completos para mvn deploy y mvn deploy -e continuación)

settings.xml :

<?xml version="1.0" encoding="UTF-8"?> <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> <servers> <server> <id>ossrh</id> <username>MY_SONATYPE_DOT_COM_USERNAME</username> <password>MY_SONATYPE_DOT_COM_PASSWORD</password> </server> </servers> <pluginGroups></pluginGroups> <proxies></proxies> <mirrors></mirrors> <profiles></profiles> </settings>

pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.github.aliteralmind</groupId> <artifactId>xbnjava</artifactId> <packaging>pom</packaging> <version>0.1.2</version> <name>XBN-Java</name> <url>https://github.com/aliteralmind/xbnjava</url> <inceptionYear>2014</inceptionYear> <organization> <name>Jeff Epstein</name> </organization> <description>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).</description> <parent> <groupId>org.sonatype.oss</groupId> <artifactId>oss-parent</artifactId> <version>7</version> </parent> <licenses> <license> <name>Lesser General Public License (LGPL) version 3.0</name> <url>https://www.gnu.org/licenses/lgpl-3.0.txt</url> </license> <license> <name>Apache Software License (ASL) version 2.0</name> <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url> </license> </licenses> <developers> <developer> <name>Jeff Epstein</name> <email>[email protected]</email> <roles> <role>Lead Developer</role> </roles> </developer> </developers> <issueManagement> <system>GitHub Issue Tracker</system> <url>https://github.com/aliteralmind/xbnjava/issues</url> </issueManagement> <distributionManagement> <snapshotRepository> <id>ossrh</id> <url>https://oss.sonatype.org/content/repositories/snapshots</url> </snapshotRepository> </distributionManagement> <scm> <connection>scm:git:[email protected]:aliteralmind/xbnjava.git</connection> <url>scm:git:[email protected]:aliteralmind/xbnjava.git</url> <developerConnection>scm:git:[email protected]:aliteralmind/xbnjava.git</developerConnection> </scm> <properties> <java.version>1.7</java.version> <jarprefix>R:/jeffy/programming/build//${project.artifactId}-${project.version}/download/${project.artifactId}-${project.version}</jarprefix> </properties> <!-- <profiles> <profile> <id>default-tools.jar</id> <activation> <property> <name>java.vendor</name> <value>Sun Microsystems Inc.</value> </property> </activation> <dependencies> <dependency> <groupId>com.sun</groupId> <artifactId>tools</artifactId> <version>1.4.2</version> <scope>system</scope> <systemPath>${java.home}/../lib/tools.jar</systemPath> </dependency> </dependencies> </profile> </profiles> --> <build> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>build-helper-maven-plugin</artifactId> <version>1.8</version> <executions> <execution> <id>attach-artifacts</id> <phase>package</phase> <goals> <goal>attach-artifact</goal> </goals> <configuration> <artifacts> <artifact> <file>${jarprefix}-all.jar</file> <type>jar</type> </artifact> </artifacts> </configuration> </execution> </executions> </plugin> </plugins> </build> <profiles> <!-- This profile will sign the JAR file, sources file, and javadocs file using the GPG key on the local machine. See: https://docs.sonatype.org/display/Repository/How+To+Generate+PGP+Signatures+With+Maven --> <profile> <id>release-sign-artifacts</id> <activation> <property> <name>release</name> <value>true</value> </property> </activation> </profile> </profiles> </project>

------------------

mvn deploy completos para mvn deploy y mvn deploy -e

mvn deploy output:

[INFO] Scanning for projects... [INFO] ------------------------------------------------------------------------ [INFO] Building XBN-Java 0.1.2 [INFO] ------------------------------------------------------------------------ [INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ xbnjava --- [INFO] --- build-helper-maven-plugin:1.8:attach-artifact (attach-artifacts) @ xbnjava --- [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.2/xbnjava-0.1.2.pom [INFO] Installing R:/jeffy/programming/build/xbnjava-0.1.2/download/xbnjava-0.1.2-all.jar to C:/Users/jeffy/.m2/repository/com/github/aliteralmind/xbnjava/0.1.2/xbnjava-0.1.2.jar [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.2/xbnjava-0.1.2.pom 2/6 KB 4/6 KB 6/6 KB

(Sección de falla :)

[INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 3.204 s [INFO] Finished at: 2014-07-18T11:25:17-04:00 [INFO] Final Memory: 7M/17M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project xbnjava: Failed to deploy artifacts: Could not transfer artifact com.github.aliteralmind:xbnjava:pom:0.1.2 from/to sonatype-nexus-staging (https://oss.sonatype.org/service/local/staging/deploy/maven2/): Failed to transfer file: https://oss.sonatype.org/service/local/staging/deploy/maven2/com/github/aliteralmind/xbnjava/0.1.2/xbnjava-0.1.2.pom. Return code is: 401, ReasonPhrase: Unauthorized. -> [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/MojoExecutionException

mvn deploy -e salida:

[INFO] Error stacktraces are turned on. [INFO] Scanning for projects... [INFO] ------------------------------------------------------------------------ [INFO] Building XBN-Java 0.1.2 [INFO] ------------------------------------------------------------------------ [INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ xbnjava --- [INFO] --- build-helper-maven-plugin:1.8:attach-artifact (attach-artifacts) @ xbnjava --- [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.2/xbnjava-0.1.2.pom [INFO] Installing R:/jeffy/programming/build/xbnjava-0.1.2/download/xbnjava-0.1.2-all.jar to C:/Users/jeffy/.m2/repository/com/github/aliteralmind/xbnjava/0.1.2/xbnjava-0.1.2.jar [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.2/xbnjava-0.1.2.pom 2/6 KB 4/6 KB 6/6 KB

(Sección de falla :)

[INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 3.492 s [INFO] Finished at: 2014-07-18T11:25:37-04:00 [INFO] Final Memory: 7M/17M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project xbnjava: Failed to deploy artifacts: Could not transfer artifact com.github.aliteralmind:xbnjava:pom:0.1.2 from/to sonatype-nexus-staging (https://oss.sonatype.org/service/local/staging/deploy/maven2/): Failed to transfer file: https://oss.sonatype.org/service/local/staging/deploy/maven2/com/github/aliteralmind/xbnjava/0.1.2/xbnjava-0.1.2.pom. Return code is: 401, ReasonPhrase: Unauthorized. -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project xbnjava: Failed to deploy artifacts: Could not transfer artifact com.github.aliteralmind:xbnjava:pom:0.1.2 from/to sonatype-nexus-staging (https://oss.sonatype.org/service/local/staging/deploy/maven2/): Failed to transfer file: https://oss.sonatype.org/service/local/staging/deploy/maven2/com/github/aliteralmind/xbnjava/0.1.2/xbnjava-0.1.2.pom. Return code is: 401, ReasonPhrase: Unauthorized. at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:347) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:154) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:213) at org.apache.maven.cli.MavenCli.main(MavenCli.java:157) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356) Caused by: org.apache.maven.plugin.MojoExecutionException: Failed to deploy artifacts: Could not transfer artifact com.github.aliteralmind:xbnjava:pom:0.1.2 from/to sonatype-nexus-staging (https://oss.sonatype.org/service/local/staging/deploy/maven2/): Failed to transfer file: https://oss.sonatype.org/service/local/staging/deploy/maven2/com/github/aliteralmind/xbnjava/0.1.2/xbnjava-0.1.2.pom. Return code is: 401, ReasonPhrase: Unauthorized. at org.apache.maven.plugin.deploy.DeployMojo.execute(DeployMojo.java:193) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208) ... 19 more Caused by: org.apache.maven.artifact.deployer.ArtifactDeploymentException: Failed to deploy artifacts: Could not transfer artifact com.github.aliteralmind:xbnjava:pom:0.1.2 from/to sonatype-nexus-staging (https://oss.sonatype.org/service/local/staging/deploy/maven2/): Failed to transfer file: https://oss.sonatype.org/service/local/staging/deploy/maven2/com/github/aliteralmind/xbnjava/0.1.2/xbnjava-0.1.2.pom. Return code is: 401, ReasonPhrase: Unauthorized. at org.apache.maven.artifact.deployer.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:143) at org.apache.maven.plugin.deploy.AbstractDeployMojo.deploy(AbstractDeployMojo.java:167) at org.apache.maven.plugin.deploy.DeployMojo.execute(DeployMojo.java:149) ... 21 more Caused by: org.eclipse.aether.deployment.DeploymentException: Failed to deploy artifacts: Could not transfer artifact com.github.aliteralmind:xbnjava:pom:0.1.2 from/to sonatype-nexus-staging (https://oss.sonatype.org/service/local/staging/deploy/maven2/): Failed to transfer file: https://oss.sonatype.org/service/local/staging/deploy/maven2/com/github/aliteralmind/xbnjava/0.1.2/xbnjava-0.1.2.pom. Return code is: 401, ReasonPhrase: Unauthorized. at org.eclipse.aether.internal.impl.DefaultDeployer.deploy(DefaultDeployer.java:337) at org.eclipse.aether.internal.impl.DefaultDeployer.deploy(DefaultDeployer.java:268) at org.eclipse.aether.internal.impl.DefaultRepositorySystem.deploy(DefaultRepositorySystem.java:413) at org.apache.maven.artifact.deployer.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:139) ... 23 more Caused by: org.eclipse.aether.transfer.ArtifactTransferException: Could not transfer artifact com.github.aliteralmind:xbnjava:pom:0.1.2 from/to sonatype-nexus-staging (https://oss.sonatype.org/service/local/staging/deploy/maven2/): Failed to transfer file: https://oss.sonatype.org/service/local/staging/deploy/maven2/com/github/aliteralmind/xbnjava/0.1.2/xbnjava-0.1.2.pom. Return code is: 401, ReasonPhrase: Unauthorized. at org.eclipse.aether.connector.wagon.WagonRepositoryConnector$6.wrap(WagonRepositoryConnector.java:1016) at org.eclipse.aether.connector.wagon.WagonRepositoryConnector$6.wrap(WagonRepositoryConnector.java:1004) at org.eclipse.aether.connector.wagon.WagonRepositoryConnector$PutTask.run(WagonRepositoryConnector.java:895) at org.eclipse.aether.connector.wagon.WagonRepositoryConnector.put(WagonRepositoryConnector.java:522) at org.eclipse.aether.internal.impl.DefaultDeployer.deploy(DefaultDeployer.java:331) ... 26 more Caused by: org.apache.maven.wagon.TransferFailedException: Failed to transfer file: https://oss.sonatype.org/service/local/staging/deploy/maven2/com/github/aliteralmind/xbnjava/0.1.2/xbnjava-0.1.2.pom. Return code is: 401, ReasonPhrase: Unauthorized. at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.put(AbstractHttpClientWagon.java:573) at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.put(AbstractHttpClientWagon.java:493) at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.put(AbstractHttpClientWagon.java:474) at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.put(AbstractHttpClientWagon.java:454) at org.eclipse.aether.connector.wagon.WagonRepositoryConnector$PutTask.run(WagonRepositoryConnector.java:871) ... 28 more [ERROR] [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/MojoExecutionException


Algunos usuarios pueden haber ingresado la dirección de correo electrónico en lugar del nombre de usuario por error. Esto puede suceder inconscientemente cuando el nombre en la dirección de correo electrónico es el mismo que el nombre de usuario.


Como se indica en la respuesta de @John, el hecho de que ya hay un 0.1.2-SNAPSHOT , interfirió con mi nueva versión no-SNAPSHOT 0.1.2 . Dado que el error 401 Unauthorized es nebuloso e inútil, y normalmente está asociado a problemas de usuario / pase, no sorprende que no haya sido capaz de resolver esto por mi cuenta.

Cambiar la versión a 0.1.3 me devuelve a mi error original:

[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].

Una persona de soporte de sonatype también me recomendó que eliminé el bloque <parent> de mi POM (solo está allí porque está en el de ez-vcard , que es con lo que comencé) y reemplazo mi bloque <distributionManagement> con

<distributionManagement> <snapshotRepository> <id>ossrh</id> <url>https://oss.sonatype.org/content/repositories/snapshots</url> </snapshotRepository> <repository> <id>ossrh</id> <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url> </repository> </distributionManagement> and then make sure that lines up with what''s in your settings.xml: <settings> <servers> <server> <id>ossrh</id> <username>your-jira-id</username> <password>your-jira-pwd</password> </server> </servers> </settings>

¡Después de hacer esto, ejecutar mvn deploy subió realmente uno de mis jarros por primera vez!

Salida:

[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

(Porción de éxito :)

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] ------------------------------------------------------------------------

Aquí está el POM completo:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.github.aliteralmind</groupId> <artifactId>xbnjava</artifactId> <packaging>pom</packaging> <version>0.1.3</version> <name>XBN-Java</name> <url>https://github.com/aliteralmind/xbnjava</url> <inceptionYear>2014</inceptionYear> <organization> <name>Jeff Epstein</name> </organization> <description>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).</description> <licenses> <license> <name>Lesser General Public License (LGPL) version 3.0</name> <url>https://www.gnu.org/licenses/lgpl-3.0.txt</url> </license> <license> <name>Apache Software License (ASL) version 2.0</name> <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url> </license> </licenses> <developers> <developer> <name>Jeff Epstein</name> <email>[email protected]</email> <roles> <role>Lead Developer</role> </roles> </developer> </developers> <issueManagement> <system>GitHub Issue Tracker</system> <url>https://github.com/aliteralmind/xbnjava/issues</url> </issueManagement> <distributionManagement> <snapshotRepository> <id>ossrh</id> <url>https://oss.sonatype.org/content/repositories/snapshots</url> </snapshotRepository> <repository> <id>ossrh</id> <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url> </repository> </distributionManagement> <scm> <connection>scm:git:[email protected]:aliteralmind/xbnjava.git</connection> <url>scm:git:[email protected]:aliteralmind/xbnjava.git</url> <developerConnection>scm:git:[email protected]:aliteralmind/xbnjava.git</developerConnection> </scm> <properties> <java.version>1.7</java.version> <jarprefix>R:/jeffy/programming/build//${project.artifactId}-${project.version}/download/${project.artifactId}-${project.version}</jarprefix> </properties> <build> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>build-helper-maven-plugin</artifactId> <version>1.8</version> <executions> <execution> <id>attach-artifacts</id> <phase>package</phase> <goals> <goal>attach-artifact</goal> </goals> <configuration> <artifacts> <artifact> <file>${jarprefix}.jar</file> <type>jar</type> </artifact> </artifacts> </configuration> </execution> </executions> </plugin> </plugins> </build> <profiles> <!-- This profile will sign the JAR file, sources file, and javadocs file using the GPG key on the local machine. See: https://docs.sonatype.org/display/Repository/How+To+Generate+PGP+Signatures+With+Maven --> <profile> <id>release-sign-artifacts</id> <activation> <property> <name>release</name> <value>true</value> </property> </activation> </profile> </profiles> </project>

Ese es un gran problema de Maven fuera del camino. Solo quedan 627 más.


Esta es la explicación oficial del equipo sonatype nexus sobre 401 - No autorizado

Te recomiendo que leas Solución de problemas de fallas en la implementación de artefactos para obtener más información.

Código 401 - No autorizado

O bien, no se enviaron credenciales de inicio de sesión con la solicitud, o se enviaron credenciales de inicio de sesión que no son válidas. Checking the "authorization and authentication" system feed in the Nexus UI can help narrow this down. If credentials were sent there will be an entry in the feed.

If no credentials were sent this is likely due to a mis-match between the id in your pom''s distributionManagement section and your settings.xml''s server section that holds the login credentials.


He tenido errores similares al intentar implementar un artefacto de Gradle en un repositorio de Nexus Sonatype. Obtendrá un error 401 no autorizado si proporciona las credenciales incorrectas (contraseña, etc.). También obtienes un error (y fuera de mi cabeza también un 401) si tratas de publicar algo en un repositorio de versiones y esa versión ya existe en el repositorio. Entonces, puede encontrar que al publicar desde la línea de comandos funciona, pero cuando lo hace desde un script falla (porque no existía en el repositorio la primera vez). O publique utilizando un número de versión diferente, o elimine el antiguo artefacto en el servidor y vuelva a publicar.

El repositorio SNAPSHOTS (a diferencia del repositorio de releases) le permite sobrescribir una versión numerada de manera similar, pero su número de versión debe tener "-SNAPSHOT" al final.


Hemos tenido este problema bastante recientemente y descubrimos que tenía que ver con la versión de Maven que estábamos usando. Estábamos usando 3.1.0 y no pudimos subir a nexus, seguimos obteniendo 401, volvimos a 3.0.3 y el problema desapareció.

La manera más fácil de confirmar es trabajar a través de las versiones maven y ejecutar "mvn deploy" en su proyecto.

Se pueden encontrar más detalles aquí: https://issues.apache.org/jira/browse/WAGON-421


Puse una contraseña no encriptada en settings.xml.

Probé la llamada con curl

curl -u username:password http://url/artifactory/libs-snapshot-local/com/myproject/api/1.0-SNAPSHOT/api-1.0-20160128.114425-1.jar --request PUT --data target/api-1.0-SNAPSHOT.jar

y recibí el error:

{ "errors" : [ { "status" : 401, "message" : "Artifactory configured to accept only encrypted passwords but received a clear text password." } ] }

Recuperé mi contraseña encriptada haciendo clic en mi perfil de artefacto y desbloqueándolo.


Uno de los motivos de este error es cuando repositoryId no está especificado o especificado incorrectamente. Como se mencionó anteriormente, debería ser el mismo que en la sección en settings.xml. Un par de pistas ... Ejecute mvn con las opciones -e -X y verifique la salida de depuración. Le dirá qué repositorio está usando:

[DEBUG] (f) offline = false [DEBUG] (f) packaging = exe [DEBUG] (f) pomFile = c:/temp/build-test/pom.xml [DEBUG] (f) project = MavenProject: org.apache.maven:standalone-pom:1 @ [DEBUG] (f) repositoryId = remote-repository [DEBUG] (f) repositoryLayout = default [DEBUG] (f) retryFailedDeploymentCount = 1 [DEBUG] (f) uniqueVersion = true [DEBUG] (f) updateReleaseInfo = false [DEBUG] (f) url = https://nexus.url.blah.com/... [DEBUG] (f) version = 13.1 [DEBUG] -- end configuration --

En este caso, utiliza el valor predeterminado "repositorio remoto", lo que significa que algo salió mal.

Aparentemente, he especificado -DrepositoryID (note ID en mayúscula) en lugar de -DrepositoryId.


Yo tenía el mismo error. I tried and rechecked everything. I was so focused in the Stack trace that I didn''t read the last lines of the build before the Reactor summary and the stack trace:

[DEBUG] Using connector AetherRepositoryConnector with priority 3.4028235E38 for http://www:8081/nexus/content/repositories/snapshots/ [INFO] Downloading: http://www:8081/nexus/content/repositories/snapshots/com/wdsuite/com.wdsuite.server.product/1.0.0-SNAPSHOT/maven-metadata.xml [DEBUG] Could not find metadata com.group:artifact.product:version-SNAPSHOT/maven-metadata.xml in nexus (http://www:8081/nexus/content/repositories/snapshots/) [DEBUG] Writing tracking file /home/me/.m2/repository/com/group/project/version-SNAPSHOT/resolver-status.properties [INFO] Uploading: http://www:8081/nexus/content/repositories/snapshots/com/...-1.0.0-20141118.124526-1.zip [INFO] Uploading: http://www:8081/nexus/content/repositories/snapshots/com/...-1.0.0-20141118.124526-1.pom [INFO] ------------------------------------------------------------------------ [INFO] Reactor Summary:

This was the key : "Could not find metadata" . Although it said that it was an authentication error actually it got fixed doing a "rebuild metadata" in the nexus repository.

Espero eso ayude.


simplemente cambie en settings.xml estos como aliteralmind dice:

<username>MY_SONATYPE_DOT_COM_USERNAME</username> <password>MY_SONATYPE_DOT_COM_PASSWORD</password>

probablemente necesite obtener el nombre de usuario / contraseña de sonatype dot com.


Also had 401''s from Nexus. Having tried all the suggestions above and more without success I eventually found that it was a Jenkins setting that was in error.

In the Jenkins configuration for the failing project, we have a section in the ''Post Build'' actions entitled ''Deploy Artifacts To Maven Repository''. This has a ''Repository ID'' field which was set to the wrong value. It has to be the same as the repository ID in settings.xml for Jenkins to read the user and password fields:

<servers> <server> <id>snapshot-repository</id> <!-- must match this --> <username>deployment</username> <password>password</password> </server> </servers>


Also, after you''ve updated your repository ids, make sure you run clean as release:prepare will pick up where it left off. Entonces puedes hacer:

mvn release:prepare -Dresume=false or

mvn release:clean release:prepare


I was dealing with this running Artifactory version 5.8.4. The "Set Me Up" function would generate settings.xml as follows:

<servers> <server> <username>${security.getCurrentUsername()}</username> <password>${security.getEscapedEncryptedPassword()!"AP56eMPz8L12T5u4J6rWdqWqyhQ"}</password> <id>central</id> </server> <server> <username>${security.getCurrentUsername()}</username> <password>${security.getEscapedEncryptedPassword()!"AP56eMPz8L12T5u4J6rWdqWqyhQ"}</password> <id>snapshots</id> </server> </servers>

After using the mvn deploy -e -X switch, I noticed the credentials were not accurate. I removed the ${security.getCurrentUsername()} and replaced it with my username and removed ${security.getEscapedEncryptedPassword()!""} and just put my encrypted password which worked for me:

<servers> <server> <username>username</username> <password>AP56eMPz8L12T5u4J6rWdqWqyhQ</password> <id>central</id> </server> <server> <username>username</username> <password>AP56eMPz8L12T5u4J6rWdqWqyhQ</password> <id>snapshots</id> </server> </servers>

¡Espero que esto ayude!


There are two setting.xml in windows.

  • %MAVEN_HOME%/conf/
  • %userprofile%/.m2/

If %userprofile%/.m2/setting.xml takes effect, maven will not access %MAVEN_HOME%/conf/setting.xml .


in my case, after encrypting password,I forgot to put settings-security.xml into ~/.m2。