Nexus error 405

I am deploying an artifact to a Nexus snapshot repository that allows redeployment, using the maven command: mvn deploy:deploy-file -Durl=https://nexus.perque.com/repo/browse /pont-aeri -Drepositor...

I am deploying an artifact to a Nexus snapshot repository that allows redeployment, using the maven command:

mvn deploy:deploy-file -Durl=https://nexus.perque.com/repo/browse
/pont-aeri -DrepositoryId=tomcat-nexus.devops-snapshots -DgroupId=com.pont.aeri.pastis -DartifactId=pastis -Dversion=0.0.1-SNAPSHOT -Dpackaging=zip  -Dfile=D:UserspastisIdeaProjectspastispastis-webtargetpastis.war

but I have this error:

rds/0.0.2/pastis.zip 405 Method Not Allowed
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (Sin

asked Aug 14, 2020 at 14:21

David Àlvarez Tudela's user avatar

4

I have never seen a mvn deploy:deploy-file to a nexus/repo/browse URL: browse should not be used for deploying files, only for… browsing them.

A typical call would be

mvn deploy:deploy-file 
  -Dfile=/path/to/a/file 
  -Dpackaging=jar -DgroupId=<aGroup> -DartifactId=<anArtifactId> -Dversion=x.y.z-SNAPSHOT 
  -DrepositoryId=<repoId> 
  -Durl==https://nexus.perque.com/content/repositories/repos-snapshots/

(Replace repos-snapshots by the name you gave to the hosted snapshot repositories)

answered Aug 16, 2020 at 16:31

VonC's user avatar

Я создал репозитории прокси в Nexus 3, указывающие на размещенные Nexus 2 репозитории. Это делается для создания снимков и выпуска репозиториев на Nexus 2. Теперь, в теге distributionManagement, я использую URL-адреса прокси и пытаюсь выполнить mvn clean deploy. Я получаю следующую ошибку:

[INFO] Error deploying artifact: Failed to transfer file: http://nexus3url/repository/m2-snapshots/path/abc-1.1.4-SNAPSHOT.pom. Return code is: 405

Has anyone tried this?

3 ответа

Лучший ответ

Как указано в комментариях, вы можете развернуть только Maven Hosted Repositories, но не прокси. Это сделано намеренно.


10

DarthHater
15 Ноя 2016 в 19:29

Тип вашей папки Nexus должен быть хостом, и попробуйте

mvn deploy 

Команда с помощью конвейера.

configFileProvider([configFile(fileId: '1880060f-32be-4888-a77d-eb046cab6981', variable: 'MAVEN_SETTINGS')]) {
sh "/jenkins_new/jenkins/home/tools/hudson.tasks.Maven_MavenInstallation/Maven_3.5.0/bin/mvn -s $MAVEN_SETTINGS deploy:deploy-file -DgroupId=net.cyc -DartifactId=${pom.artifactId} -Dversion=${pom.version} -DgeneratePom=true  -Dpackaging=jar -DrepositoryId=nbtnexus -Durl=https://dexus.connectcare.net/repository/maven-snapshots/  -DpomFile=pom.xml -Dfile=target/${pom.artifactId}-${pom.version}.${pom.packaging}"                    

    }


0

alepuzio
12 Дек 2018 в 17:21

Я столкнулся с той же проблемой, когда пытаюсь развернуть приложение в репозиторий nexus 3. В моем случае URL-адрес не прокси, но путь был неправильным.

Если вы пытаетесь развернуть версию моментального снимка, убедитесь, что URL-адрес указывает на расположение репозитория моментальных снимков нексуса. если это версия выпуска, URL-адрес должен указывать на репозиторий выпуска.


1

Kishor K
18 Апр 2017 в 02:09

I’m testing the locally deployed Nexus using a Demo Project. I’ve created this repo: com.example on Nexus using create Repository. The URL of the repository on local Nexus is: http://localhost:8081/repository/com.example/.

The configuration in build.sbt goes like:

name := "data-models"

version := "0.1"

scalaVersion := "2.12.7"

organization := "com.example"

val snapshotsName = "Repository Snapshots"
val snapshotsUrl = new java.net.URL("http://localhost:8081/repository/com.example/")
val snapshotsPattern = "[organisation]/[module]/[revision]-SNAPSHOT/[artifact]-[revision](-[timestamp]).[ext]"
val snapshots = Resolver.url(snapshotsName, snapshotsUrl)(Patterns(snapshotsPattern))
credentials += Credentials(Path.userHome / ".ivy2" / ".credentials")

publishTo := Some("Sonatype Nexus Repository Manager" at "http://localhost:8081/repository/com.example/")

The Credentials conf goes like:

realm=Sonatype Nexus Repository Manager
host=localhost:8081
user=admin
password=qwerty123#345ty

Then I try to run sbt publish.

I get this error:

[info] Loading project definition from /home/yash/IdeaProjects/data-models/project
[info] Loading settings for project data-models from build.sbt ...
[info] Set current project to data-models (in build file:/home/yash/IdeaProjects/data-models/)
[info] Packaging /home/yash/IdeaProjects/data-models/target/scala-2.12/data-models_2.12-0.1-sources.jar ...
[info] Updating ...
[info] Done packaging.
[info] Done updating.
[info] Wrote /home/yash/IdeaProjects/data-models/target/scala-2.12/data-models_2.12-0.1.pom
[info] Packaging /home/yash/IdeaProjects/data-models/target/scala-2.12/data-models_2.12-0.1.jar ...
[info] Done packaging.
[error] java.io.IOException: PUT operation to URL http://localhost:8081/com/example/data-models_2.12/0.1/data-models_2.12-0.1.pom failed with status code 405: HTTP method PUT is not supported by this URL
[error]         at org.apache.ivy.util.url.AbstractURLHandler.validatePutStatusCode(AbstractURLHandler.java:82)
[error]         at sbt.internal.librarymanagement.ivyint.GigahorseUrlHandler.upload(GigahorseUrlHandler.scala:191)
[error]         at org.apache.ivy.util.url.URLHandlerDispatcher.upload(URLHandlerDispatcher.java:82)
[error]         at org.apache.ivy.util.FileUtil.copy(FileUtil.java:150)
[error]         at org.apache.ivy.plugins.repository.url.URLRepository.put(URLRepository.java:84)
[error]         at sbt.internal.librarymanagement.ConvertResolver$LocalIfFileRepo.put(ConvertResolver.scala:366)
[error]         at org.apache.ivy.plugins.repository.AbstractRepository.put(AbstractRepository.java:130)
[error]         at sbt.internal.librarymanagement.ConvertResolver$ChecksumFriendlyURLResolver.put(ConvertResolver.scala:118)
[error]         at sbt.internal.librarymanagement.ConvertResolver$ChecksumFriendlyURLResolver.put$(ConvertResolver.scala:105)
[error]         at sbt.internal.librarymanagement.ConvertResolver$$anonfun$defaultConvert$lzycompute$1$PluginCapableResolver$1.put(ConvertResolver.scala:165)
[error]         at org.apache.ivy.plugins.resolver.RepositoryResolver.publish(RepositoryResolver.java:216)
[error]         at sbt.internal.librarymanagement.IvyActions$.$anonfun$publish$5(IvyActions.scala:497)
[error]         at sbt.internal.librarymanagement.IvyActions$.$anonfun$publish$5$adapted(IvyActions.scala:496)
[error]         at scala.collection.TraversableLike$WithFilter.$anonfun$foreach$1(TraversableLike.scala:788)
[error]         at scala.collection.Iterator.foreach(Iterator.scala:937)
[error]         at scala.collection.Iterator.foreach$(Iterator.scala:937)
[error]         at scala.collection.AbstractIterator.foreach(Iterator.scala:1425)
[error]         at scala.collection.IterableLike.foreach(IterableLike.scala:70)
[error]         at scala.collection.IterableLike.foreach$(IterableLike.scala:69)
[error]         at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
[error]         at scala.collection.TraversableLike$WithFilter.foreach(TraversableLike.scala:787)
[error]         at sbt.internal.librarymanagement.IvyActions$.publish(IvyActions.scala:496)
[error]         at sbt.internal.librarymanagement.IvyActions$.$anonfun$publish$3(IvyActions.scala:144)
[error]         at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
[error]         at sbt.internal.librarymanagement.IvyActions$.withChecksums(IvyActions.scala:157)
[error]         at sbt.internal.librarymanagement.IvyActions$.withChecksums(IvyActions.scala:151)
[error]         at sbt.internal.librarymanagement.IvyActions$.$anonfun$publish$1(IvyActions.scala:144)
[error]         at sbt.internal.librarymanagement.IvyActions$.$anonfun$publish$1$adapted(IvyActions.scala:134)
[error]         at sbt.internal.librarymanagement.IvySbt$Module.$anonfun$withModule$1(Ivy.scala:239)
[error]         at sbt.internal.librarymanagement.IvySbt.$anonfun$withIvy$1(Ivy.scala:204)
[error]         at sbt.internal.librarymanagement.IvySbt.sbt$internal$librarymanagement$IvySbt$$action$1(Ivy.scala:70)
[error]         at sbt.internal.librarymanagement.IvySbt$$anon$3.call(Ivy.scala:77)
[error]         at xsbt.boot.Locks$GlobalLock.withChannel$1(Locks.scala:95)
[error]         at xsbt.boot.Locks$GlobalLock.xsbt$boot$Locks$GlobalLock$$withChannelRetries$1(Locks.scala:80)
[error]         at xsbt.boot.Locks$GlobalLock$$anonfun$withFileLock$1.apply(Locks.scala:99)
[error]         at xsbt.boot.Using$.withResource(Using.scala:10)
[error]         at xsbt.boot.Using$.apply(Using.scala:9)
[error]         at xsbt.boot.Locks$GlobalLock.ignoringDeadlockAvoided(Locks.scala:60)
[error]         at xsbt.boot.Locks$GlobalLock.withLock(Locks.scala:50)
[error]         at xsbt.boot.Locks$.apply0(Locks.scala:31)
[error]         at xsbt.boot.Locks$.apply(Locks.scala:28)
[error]         at sbt.internal.librarymanagement.IvySbt.withDefaultLogger(Ivy.scala:77)
[error]         at sbt.internal.librarymanagement.IvySbt.withIvy(Ivy.scala:199)
[error]         at sbt.internal.librarymanagement.IvySbt.withIvy(Ivy.scala:196)
[error]         at sbt.internal.librarymanagement.IvySbt$Module.withModule(Ivy.scala:238)
[error]         at sbt.internal.librarymanagement.IvyActions$.publish(IvyActions.scala:134)
[error]         at sbt.Classpaths$.$anonfun$publishTask$4(Defaults.scala:2411)
[error]         at sbt.Classpaths$.$anonfun$publishTask$4$adapted(Defaults.scala:2411)
[error]         at scala.Function1.$anonfun$compose$1(Function1.scala:44)
[error]         at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:40)
[error]         at sbt.std.Transform$$anon$4.work(System.scala:67)
[error]         at sbt.Execute.$anonfun$submit$2(Execute.scala:269)
[error]         at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:16)
[error]         at sbt.Execute.work(Execute.scala:278)
[error]         at sbt.Execute.$anonfun$submit$1(Execute.scala:269)
[error]         at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:178)
[error]         at sbt.CompletionService$$anon$2.call(CompletionService.scala:37)
[error]         at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error]         at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
[error]         at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error]         at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[error]         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[error]         at java.lang.Thread.run(Thread.java:748)
[error] (publish) java.io.IOException: PUT operation to URL http://localhost:8081/com/example/data-models_2.12/0.1/data-models_2.12-0.1.pom failed with status code 405: HTTP method PUT is not supported by this URL

I’m not able to understand what’s wrong. Is it the correct way to do it?
What is the correct way?

Thanks in Advance.

Attaching a Screenshot of the Nexus repo.

enter image description here

If you’re getting a 405 error when trying to deploy a file to your Maven repository, it’s because the URL (as in -Durl=http://host.com/repo) you have specified is somehow incorrect.

For example, I was trying to deploy a file using the mvn deploy:deploy-file target to a Nexus repository, and I got the following error:


$ mvn deploy:deploy-file -DgroupId=com.austje.test -DartifactId=project -Dversion=1.0 -Dpackaging=jar -Dfile=project.jar -Durl=http://repo1.austje.com/ -DrepositoryId=MyReleases
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'deploy'.
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Default Project
[INFO]    task-segment: [deploy:deploy-file] (aggregator-style)
[INFO] ------------------------------------------------------------------------
[INFO] [deploy:deploy-file {execution: default-cli}]
Uploading: http://repo1.austje.com//com/austje/test/project/1.0/project-1.0.jar
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error deploying artifact: Failed to transfer file: http://repo1.austje.com//com/austje/test/project/1.0/project-1.0.jar. Return code is: 405
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 second
[INFO] Finished at: Mon Jan 25 11:15:25 CST 2010
[INFO] Final Memory: 5M/9M
[INFO] ------------------------------------------------------------------------

Looking at the line Uploading: http://repo1.austje.com//com/austje/test/project/1.0/project-1.0.jar, it’s pretty obvious that my url is wrong–that’s not where the artifact should be uploaded at all. Turns out I gave the repository server, but not the actual repository url! Changing my url parameter to reflect this


$ mvn deploy:deploy-file -DgroupId=com.austje.test -DartifactId=project -Dversion=1.0 -Dpackaging=jar -Dfile=workingTest.zip -Durl=http://repo1.austje.com/nexus/content/repositories/my-repo/ -DrepositoryId=MyReleases

fixed the issue, and I was able to deploy successfully.

Of course, this is not the only way you could screw up the url parameter. Among many possibilities, one tricky one I’ve seen is using http instead of https as the protocol.

Extra tip: If you fix the URL and are now getting return code 401, your credentials are incorrect. Try fixing them in your settings.xml file. You can test the credentials by going to the Nexus GUI and logging in. If those work, and you’re still not able to deploy via the command line, make sure the <id> in your <server> section of your settings.xml matches the <id> in the corresponding <repository> element.

Понравилась статья? Поделить с друзьями:
  • Nexus error 401
  • Nexus demo content error
  • Nextion editor ошибки при запуске
  • Nextion editor load dll error application run resources
  • Nexthop has invalid gateway ошибка