Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sonatypeBundleRelease erroring out with HttpClientException: [401: Unauthorized] #224

Closed
MrPowers opened this issue Apr 2, 2021 · 9 comments

Comments

@MrPowers
Copy link

MrPowers commented Apr 2, 2021

Thanks for creating this great project.

The ; + publishSigned; sonatypeBundleRelease command was working in February 2021, but is broken now. Suppose it could be related to this issue.

Here's the project build.sbt file.

Here's the full stack trace, thanks for the help!

~/D/c/m/bebe ❯❯❯ sbt
[info] welcome to sbt 1.4.3 (AdoptOpenJDK Java 1.8.0_272)
[info] loading global plugins from /Users/powers/.sbt/1.0/plugins
[info] loading settings for project bebe-build from plugins.sbt ...
[info] loading project definition from /Users/powers/Documents/code/my_apps/bebe/project
[info] loading settings for project bebe from build.sbt ...
[info] set current project to bebe (in build file:/Users/powers/Documents/code/my_apps/bebe/)
[info] sbt server started at local:///Users/powers/.sbt/1.0/server/95f89f2f7690db247a04/sock
[info] started sbt server
sbt:bebe> ; + publishSigned; sonatypeBundleRelease
[info] Setting Scala version to 2.12.12 on 1 projects.
[info] Reapplying settings...
[info] set current project to bebe (in build file:/Users/powers/Documents/code/my_apps/bebe/)
[info] Wrote /Users/powers/Documents/code/my_apps/bebe/target/scala-2.12/bebe_2.12-0.0.2.pom
[info] Main Scala API documentation to /Users/powers/Documents/code/my_apps/bebe/target/scala-2.12/api...
[info] compiling 2 Scala sources to /Users/powers/Documents/code/my_apps/bebe/target/scala-2.12/classes ...
model contains 9 documentable templates
[info] Main Scala API documentation successful.
[info]  published bebe_2.12 to /Users/powers/Documents/code/my_apps/bebe/target/sonatype-staging/0.0.2/com/github/mrpowers/bebe_2.12/0.0.2.part/bebe_2.12-0.0.2.pom.asc
[info] 	published bebe_2.12 to /Users/powers/Documents/code/my_apps/bebe/target/sonatype-staging/0.0.2/com/github/mrpowers/bebe_2.12/0.0.2.part/bebe_2.12-0.0.2.pomcts 10s
[info] 	published bebe_2.12 to /Users/powers/Documents/code/my_apps/bebe/target/sonatype-staging/0.0.2/com/github/mrpowers/bebe_2.12/0.0.2.part/bebe_2.12-0.0.2-sources.jar
[info] 	published bebe_2.12 to /Users/powers/Documents/code/my_apps/bebe/target/sonatype-staging/0.0.2/com/github/mrpowers/bebe_2.12/0.0.2.part/bebe_2.12-0.0.2.jarcts 10s
[info] 	published bebe_2.12 to /Users/powers/Documents/code/my_apps/bebe/target/sonatype-staging/0.0.2/com/github/mrpowers/bebe_2.12/0.0.2.part/bebe_2.12-0.0.2.jar.asc10s
[info] 	published bebe_2.12 to /Users/powers/Documents/code/my_apps/bebe/target/sonatype-staging/0.0.2/com/github/mrpowers/bebe_2.12/0.0.2.part/bebe_2.12-0.0.2-javadoc.jar.asc
[info] 	published bebe_2.12 to /Users/powers/Documents/code/my_apps/bebe/target/sonatype-staging/0.0.2/com/github/mrpowers/bebe_2.12/0.0.2.part/bebe_2.12-0.0.2-sources.jar.asc
[info] 	published bebe_2.12 to /Users/powers/Documents/code/my_apps/bebe/target/sonatype-staging/0.0.2/com/github/mrpowers/bebe_2.12/0.0.2.part/bebe_2.12-0.0.2-javadoc.jar
[info] 	publish commited: moved /Users/powers/Documents/code/my_apps/bebe/target/sonatype-staging/0.0.2/com/github/mrpowers/bebe_2.12/0.0.2.part ebe / signedArtifacts 10s
[info] 		to /Users/powers/Documents/code/my_apps/bebe/target/sonatype-staging/0.0.2/com/github/mrpowers/bebe_2.12/0.0.2
[success] Total time: 18 s, completed Apr 2, 2021 10:41:46 AM
[info] Reapplying settings...
[info] set current project to bebe (in build file:/Users/powers/Documents/code/my_apps/bebe/)
2021-04-02 10:41:46.797-0300  info [SonatypeService] sonatypeRepository  : https://oss.sonatype.org/service/local  - (SonatypeService.scala:24)
2021-04-02 10:41:46.799-0300  info [SonatypeService] sonatypeProfileName : com.github.mrpowers  - (SonatypeService.scala:25)
[info] Preparing a new staging repository for [sbt-sonatype] bebe 0.0.2
2021-04-02 10:41:46.801-0300  info [SonatypeClient] Reading staging repository profiles...  - (SonatypeClient.scala:109)
2021-04-02 10:41:47.795-0300  info [SonatypeClient] Reading staging profiles...  - (SonatypeClient.scala:121)
2021-04-02 10:41:48.334-0300 error [Sonatype] 
wvlet.airframe.http.HttpClientException: [401: Unauthorized]
	at wvlet.airframe.http.HttpClientException$.requestFailure(HttpClientException.scala:67)
	at wvlet.airframe.http.HttpClientException$.classifyHttpResponse(HttpClientException.scala:110)
	at wvlet.airframe.http.HttpClient$.$anonfun$defaultHttpClientRetry$1(HttpClient.scala:382)
	at wvlet.airframe.control.Retry$RetryContext.runInternal(Retry.scala:269)
	at wvlet.airframe.control.Retry$RetryContext.runWithContext(Retry.scala:257)
	at wvlet.airframe.http.client.URLConnectionClient.send(URLConnectionClient.scala:63)
	at wvlet.airframe.http.client.URLConnectionClient.get(URLConnectionClient.scala:159)
	at xerial.sbt.sonatype.SonatypeClient.stagingRepositoryProfiles(SonatypeClient.scala:111)
	at xerial.sbt.sonatype.SonatypeService.stagingRepositoryProfiles(SonatypeService.scala:114)
	at xerial.sbt.sonatype.SonatypeService.findStagingRepositoryProfilesWithKey(SonatypeService.scala:108)
	at xerial.sbt.sonatype.SonatypeService.dropIfExistsByKey(SonatypeService.scala:95)
	at xerial.sbt.Sonatype$.$anonfun$prepare$2(Sonatype.scala:142)
	at scala.concurrent.Future$.$anonfun$apply$1(Future.scala:659)
	at scala.util.Success.$anonfun$map$1(Try.scala:255)
	at scala.util.Success.map(Try.scala:213)
	at scala.concurrent.Future.$anonfun$map$1(Future.scala:292)
	at scala.concurrent.impl.Promise.liftedTree1$1(Promise.scala:33)
	at scala.concurrent.impl.Promise.$anonfun$transform$1(Promise.scala:33)
	at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:64)
	at java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1402)
	at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
	at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
	at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)  - (Sonatype.scala:409)
@amitksingh1490
Copy link

amitksingh1490 commented Apr 2, 2021

I am also facing same issue, when I am trying to use sbt-ci-release which internally used sbt-sonatype. So can't change the publishTo

@amitksingh1490
Copy link

Thanks for creating this great project.

The ; + publishSigned; sonatypeBundleRelease command was working in February 2021, but is broken now. Suppose it could be related to this issue.

Here's the project build.sbt file.

Here's the full stack trace, thanks for the help!

~/D/c/m/bebe ❯❯❯ sbt
[info] welcome to sbt 1.4.3 (AdoptOpenJDK Java 1.8.0_272)
[info] loading global plugins from /Users/powers/.sbt/1.0/plugins
[info] loading settings for project bebe-build from plugins.sbt ...
[info] loading project definition from /Users/powers/Documents/code/my_apps/bebe/project
[info] loading settings for project bebe from build.sbt ...
[info] set current project to bebe (in build file:/Users/powers/Documents/code/my_apps/bebe/)
[info] sbt server started at local:///Users/powers/.sbt/1.0/server/95f89f2f7690db247a04/sock
[info] started sbt server
sbt:bebe> ; + publishSigned; sonatypeBundleRelease
[info] Setting Scala version to 2.12.12 on 1 projects.
[info] Reapplying settings...
[info] set current project to bebe (in build file:/Users/powers/Documents/code/my_apps/bebe/)
[info] Wrote /Users/powers/Documents/code/my_apps/bebe/target/scala-2.12/bebe_2.12-0.0.2.pom
[info] Main Scala API documentation to /Users/powers/Documents/code/my_apps/bebe/target/scala-2.12/api...
[info] compiling 2 Scala sources to /Users/powers/Documents/code/my_apps/bebe/target/scala-2.12/classes ...
model contains 9 documentable templates
[info] Main Scala API documentation successful.
[info]  published bebe_2.12 to /Users/powers/Documents/code/my_apps/bebe/target/sonatype-staging/0.0.2/com/github/mrpowers/bebe_2.12/0.0.2.part/bebe_2.12-0.0.2.pom.asc
[info] 	published bebe_2.12 to /Users/powers/Documents/code/my_apps/bebe/target/sonatype-staging/0.0.2/com/github/mrpowers/bebe_2.12/0.0.2.part/bebe_2.12-0.0.2.pomcts 10s
[info] 	published bebe_2.12 to /Users/powers/Documents/code/my_apps/bebe/target/sonatype-staging/0.0.2/com/github/mrpowers/bebe_2.12/0.0.2.part/bebe_2.12-0.0.2-sources.jar
[info] 	published bebe_2.12 to /Users/powers/Documents/code/my_apps/bebe/target/sonatype-staging/0.0.2/com/github/mrpowers/bebe_2.12/0.0.2.part/bebe_2.12-0.0.2.jarcts 10s
[info] 	published bebe_2.12 to /Users/powers/Documents/code/my_apps/bebe/target/sonatype-staging/0.0.2/com/github/mrpowers/bebe_2.12/0.0.2.part/bebe_2.12-0.0.2.jar.asc10s
[info] 	published bebe_2.12 to /Users/powers/Documents/code/my_apps/bebe/target/sonatype-staging/0.0.2/com/github/mrpowers/bebe_2.12/0.0.2.part/bebe_2.12-0.0.2-javadoc.jar.asc
[info] 	published bebe_2.12 to /Users/powers/Documents/code/my_apps/bebe/target/sonatype-staging/0.0.2/com/github/mrpowers/bebe_2.12/0.0.2.part/bebe_2.12-0.0.2-sources.jar.asc
[info] 	published bebe_2.12 to /Users/powers/Documents/code/my_apps/bebe/target/sonatype-staging/0.0.2/com/github/mrpowers/bebe_2.12/0.0.2.part/bebe_2.12-0.0.2-javadoc.jar
[info] 	publish commited: moved /Users/powers/Documents/code/my_apps/bebe/target/sonatype-staging/0.0.2/com/github/mrpowers/bebe_2.12/0.0.2.part ebe / signedArtifacts 10s
[info] 		to /Users/powers/Documents/code/my_apps/bebe/target/sonatype-staging/0.0.2/com/github/mrpowers/bebe_2.12/0.0.2
[success] Total time: 18 s, completed Apr 2, 2021 10:41:46 AM
[info] Reapplying settings...
[info] set current project to bebe (in build file:/Users/powers/Documents/code/my_apps/bebe/)
2021-04-02 10:41:46.797-0300  info [SonatypeService] sonatypeRepository  : https://oss.sonatype.org/service/local  - (SonatypeService.scala:24)
2021-04-02 10:41:46.799-0300  info [SonatypeService] sonatypeProfileName : com.github.mrpowers  - (SonatypeService.scala:25)
[info] Preparing a new staging repository for [sbt-sonatype] bebe 0.0.2
2021-04-02 10:41:46.801-0300  info [SonatypeClient] Reading staging repository profiles...  - (SonatypeClient.scala:109)
2021-04-02 10:41:47.795-0300  info [SonatypeClient] Reading staging profiles...  - (SonatypeClient.scala:121)
2021-04-02 10:41:48.334-0300 error [Sonatype] 
wvlet.airframe.http.HttpClientException: [401: Unauthorized]
	at wvlet.airframe.http.HttpClientException$.requestFailure(HttpClientException.scala:67)
	at wvlet.airframe.http.HttpClientException$.classifyHttpResponse(HttpClientException.scala:110)
	at wvlet.airframe.http.HttpClient$.$anonfun$defaultHttpClientRetry$1(HttpClient.scala:382)
	at wvlet.airframe.control.Retry$RetryContext.runInternal(Retry.scala:269)
	at wvlet.airframe.control.Retry$RetryContext.runWithContext(Retry.scala:257)
	at wvlet.airframe.http.client.URLConnectionClient.send(URLConnectionClient.scala:63)
	at wvlet.airframe.http.client.URLConnectionClient.get(URLConnectionClient.scala:159)
	at xerial.sbt.sonatype.SonatypeClient.stagingRepositoryProfiles(SonatypeClient.scala:111)
	at xerial.sbt.sonatype.SonatypeService.stagingRepositoryProfiles(SonatypeService.scala:114)
	at xerial.sbt.sonatype.SonatypeService.findStagingRepositoryProfilesWithKey(SonatypeService.scala:108)
	at xerial.sbt.sonatype.SonatypeService.dropIfExistsByKey(SonatypeService.scala:95)
	at xerial.sbt.Sonatype$.$anonfun$prepare$2(Sonatype.scala:142)
	at scala.concurrent.Future$.$anonfun$apply$1(Future.scala:659)
	at scala.util.Success.$anonfun$map$1(Try.scala:255)
	at scala.util.Success.map(Try.scala:213)
	at scala.concurrent.Future.$anonfun$map$1(Future.scala:292)
	at scala.concurrent.impl.Promise.liftedTree1$1(Promise.scala:33)
	at scala.concurrent.impl.Promise.$anonfun$transform$1(Promise.scala:33)
	at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:64)
	at java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1402)
	at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
	at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
	at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)  - (Sonatype.scala:409)

For Your build.sbt publishTo := { val nexus = "https://s01.oss.sonatype.org/" if (isSnapshot.value) Some("snapshots" at nexus + "content/repositories/snapshots") else Some("releases" at nexus + "service/local/staging/deploy/maven2") } this might fix the issue

@xerial
Copy link
Owner

xerial commented Apr 2, 2021

@MrPowers If your sonatype account is created after February 2021, we need the following settings:
build.sbt

ThisBuild / sonatypeCredentialHost := "s01.oss.sonatype.org"

Your ".sbt" / "sonatype_credentials" file:

credentials += Credentials("Sonatype Nexus Repository Manager",
        "s01.oss.sonatype.org", // <-- This host name needs to have s01 prefix
        "(Sonatype user name)",
        "(Sonatype password)")

Hopefully, it would work.

@xerial
Copy link
Owner

xerial commented Apr 2, 2021

Sonatype has changed their host to s01.oss.sonatype.org https://github.com/xerial/sbt-sonatype#buildsbt for new accounts created after Feb 2021. The old sonatype accounts still need to use oss.sonatype.org

@MrPowers
Copy link
Author

MrPowers commented Apr 2, 2021

@xerial - I created my Sonatype account a long time ago. It it possible I still need to set the sonatypeCredentialHost := "s01.oss.sonatype.org"? Let me know if I should try. Thanks for the help.

@xerial
Copy link
Owner

xerial commented Apr 2, 2021

@MrPowers ok. Then, you don't need to add the above-mentioned settings. There might be other issues.

@xerial
Copy link
Owner

xerial commented Apr 2, 2021

Summary so far:

  • This problem happens in sbt-sonatype 3.9.4 with sbt 1.4.3. (Upgrading to sbt-sonatype 3.9.7 and sbt 1.4.9 may change the behavior)
  • The problem is 401 authentication failure when creating a new staging repository at Sonatype.
    • This error happens when the credential (sonatype user/password) is actually wrong. If that's the case, other commands (e.g., sonatypeStagingProfiles, sonatypeStagingRepositoryProfiles will not work, neither. @MrPowers could you try running these commands and check your credentials with show credentials command?)
    • Or there might be other changes at Sonatype side (e.g., "Sonatype Nexus Repository Manager" credential name might have changed at Sonatype)
    • I could release my project a week ago with sbt-sonatype 3.9.7 to oss.sonatype.org https://github.com/wvlet/airframe/runs/2204548923
  • This problem is not due to Sonatype's new host addition (s01.oss.sonatype.org)
  • No incident of Sonatype has been observed https://status.maven.org/

@MrPowers
Copy link
Author

MrPowers commented Apr 2, 2021

@xerial - thanks for all your help.

The sonatypeStagingProfiles and sonatypeStagingRepositoryProfiles did not work. I tried to log into the Sonatype website and that didn't work either. I reset my Sonatype password, updated my password in ~/.sbt/sonatype_credentials and then everything just started working again.

Will keep this open for a couple more days and post if I find anything else, but looks my Sonatype password became invalid, for some reason I don't understand.

@MrPowers
Copy link
Author

MrPowers commented Apr 3, 2021

Thanks again for helping me figure this out and for making this wonderful library.

@MrPowers MrPowers closed this as completed Apr 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants