xerial / sbt-sonatype

A sbt plugin for publishing Scala/Java projects to the Maven central.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NoClassDefFoundError org/apache/http/conn/HttpClientConnectionManager

exoego opened this issue · comments

I encountered a NoClassDefFoundError when I tried releasing with the latest sbt-sonatype 3.6.

[info] Reapplying settings...
[info] Set current project to root (in build file:/home/vagrant/IdeaProjects/my-project/)
[info] Nexus repository URL: https://oss.sonatype.org/service/local
[info] sonatypeProfileName = XXXXXX
[info] Preparing a new staging repository for [sbt-sonatype] root 0.0.1
[info] Reading staging repository profiles...
[info] Reading staging profiles...
[info] Found a staging repository [XXXXXX-1001] status:open, profile:XXXXXX(XXXXXX) description: [sbt-sonatype] root 0.0.1
[info] Dropping staging repository [XXXXXX-1001] status:open, profile:XXXXXX(XXXXXX) description: [sbt-sonatype] root 0.0.1
[info] Creating a staging repository in profile XXXXXX with a description key: [sbt-sonatype] root 0.0.1
[info] Dropped successfully: XXXXXX-1001
[info] Created successfully: XXXXXX-1002
[error] java.lang.NoClassDefFoundError: org/apache/http/conn/HttpClientConnectionManager
[error]         at xerial.sbt.NexusRESTService.uploadBundle(NexusClient.scala:178)
[error]         at xerial.sbt.Sonatype$.$anonfun$sonatypeBundleRelease$1(Sonatype.scala:151)
[error]         at sbt.Command$.$anonfun$command$2(Command.scala:91)
[error]         at sbtrelease.ReleasePlugin$autoImport$.$anonfun$releaseStepCommand$2(ReleasePlugin.scala:94)
[error]         at sbtrelease.ReleasePlugin$autoImport$ReleaseKeys$.filterFailure$1(ReleasePlugin.scala:177)
[error]         at sbtrelease.ReleasePlugin$autoImport$ReleaseKeys$.$anonfun$releaseCommand$9(ReleasePlugin.scala:195)
[error]         at scala.Function$.$anonfun$chain$2(Function.scala:24)
[error]         at scala.collection.LinearSeqOptimized.foldLeft(LinearSeqOptimized.scala:122)
[error]         at scala.collection.LinearSeqOptimized.foldLeft$(LinearSeqOptimized.scala:118)
[error]         at scala.collection.immutable.List.foldLeft(List.scala:85)
[error]         at scala.collection.TraversableOnce.$div$colon(TraversableOnce.scala:150)
[error]         at scala.collection.TraversableOnce.$div$colon$(TraversableOnce.scala:150)
[error]         at scala.collection.AbstractTraversable.$div$colon(Traversable.scala:104)
[error]         at scala.Function$.$anonfun$chain$1(Function.scala:24)
[error]         at sbtrelease.ReleasePlugin$autoImport$ReleaseKeys$.$anonfun$releaseCommand$2(ReleasePlugin.scala:201)
[error]         at sbt.Command$.$anonfun$applyEffect$4(Command.scala:142)
[error]         at sbt.Command$.$anonfun$applyEffect$2(Command.scala:137)
[error]         at sbt.Command$.process(Command.scala:181)
[error]         at sbt.MainLoop$.processCommand(MainLoop.scala:151)
[error]         at sbt.MainLoop$.$anonfun$next$2(MainLoop.scala:139)
[error]         at sbt.State$$anon$1.runCmd$1(State.scala:246)
[error]         at sbt.State$$anon$1.process(State.scala:250)
[error]         at sbt.MainLoop$.$anonfun$next$1(MainLoop.scala:139)
[error]         at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:16)
[error]         at sbt.MainLoop$.next(MainLoop.scala:139)
[error]         at sbt.MainLoop$.run(MainLoop.scala:132)
[error]         at sbt.MainLoop$.$anonfun$runWithNewLog$1(MainLoop.scala:110)
[error]         at sbt.io.Using.apply(Using.scala:22)
[error]         at sbt.MainLoop$.runWithNewLog(MainLoop.scala:104)
[error]         at sbt.MainLoop$.runAndClearLast(MainLoop.scala:59)
[error]         at sbt.MainLoop$.runLoggedLoop(MainLoop.scala:44)
[error]         at sbt.MainLoop$.runLogged(MainLoop.scala:35)
[error]         at sbt.StandardMain$.runManaged(Main.scala:138)
[error]         at sbt.xMain.run(Main.scala:89)
[error]         at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:109)
[error]         at xsbt.boot.Launch$.withContextLoader(Launch.scala:128)
[error]         at xsbt.boot.Launch$.run(Launch.scala:109)
[error]         at xsbt.boot.Launch$$anonfun$apply$1.apply(Launch.scala:35)
[error]         at xsbt.boot.Launch$.launch(Launch.scala:117)
[error]         at xsbt.boot.Launch$.apply(Launch.scala:18)
[error]         at xsbt.boot.Boot$.runImpl(Boot.scala:56)
[error]         at xsbt.boot.Boot$.main(Boot.scala:18)
[error]         at xsbt.boot.Boot.main(Boot.scala)

Release steps:

releaseProcess := Seq[ReleaseStep](
  checkSnapshotDependencies,
  inquireVersions,
  runTest,
  setReleaseVersion,
  commitReleaseVersion,
  tagRelease,
  runClean,
  releaseStepCommandAndRemaining("+publishSigned"),
  releaseStepCommand("sonatypeBundleRelease"),
  setNextVersion,
  commitNextVersion
),

Plugins.sbt

addSbtPlugin("org.scala-js"      % "sbt-scalajs"         % "0.6.28")
addSbtPlugin("org.xerial.sbt"    % "sbt-sonatype"        % "3.6")
addSbtPlugin("com.github.gseitz" % "sbt-release"         % "1.0.11")
addSbtPlugin("com.jsuereth"      % "sbt-pgp"             % "1.1.2")
  • Scala versions: 2.19.0, 2.13.0
  • Sbt version: 1.2.8
  • Java version
openjdk version "11.0.4" 2019-07-16
OpenJDK Runtime Environment (build 11.0.4+11-post-Ubuntu-1ubuntu218.04.3)
OpenJDK 64-Bit Server VM (build 11.0.4+11-post-Ubuntu-1ubuntu218.04.3, mixed mode, sharing)

Eviction warning on sbt-sonatype project.

sbt:sbt-sonatype> evicted
[info] Updating ProjectRef(uri("file:/home/vagrant/IdeaProjects/sbt-sonatype/"), "sbt-sonatype")...
[info] Done updating.
[info] Here are other dependency conflicts that were resolved:
[info]  * org.apache.httpcomponents:httpclient:4.5.9 is selected over 4.3.5
[info]      +- org.xerial.sbt:sbt-sonatype:3.7-SNAPSHOT (scalaVersion=2.12, sbtVersion=1.0) (depends on 4.3.5)
[info]      +- org.sonatype.spice.zapper:spice-zapper:1.3         (depends on 4.3.5)

The error is resolved and I can successfully release my artifacts after sbt updated to 1.3.0.
Maybe I forgot to reload sbt after updating sbt-release to 3.6, so httpclient not installed... ?
But if so, sonatypeBundleRelease command should not be recognized...

I guess it's not the issue of the plugin itself if your problem is resolved by updating the sbt version. It looks like caching of the plugin dependencies might have some issues in 1.2.x series.

Let me close this issue. If you still see this error, feel free to reopen it.

I'm getting the same error with sbt 1.2.8. A workaround is to specify
libraryDependencies += "org.apache.httpcomponents" % "httpclient" % "4.5.10"
for the build, e.g. in the plugins.sbt

IMO this should be mentioned in the readme (unless you have an idea to fix it, of course). Thoughts?

So it seems that sbt-sonatype fails to include transitive dependency (httpclient).
A workaround should be mentioned for users statying sbt 1.2.8, or bugfix is required.
Unfortunately I can't reopen since I don't see reopen button.

No. sbt-sonatype has the direct dependency to http-client:

"org.apache.httpcomponents" % "httpclient" % "4.5.10",

If the dependency cannot be properly downloaded, it should be sbt's issue.

Based on @mpollmeier's comment, I assume using httpclient 4.5.10 can resolve this issue. I'll release sbt-sonatype 3.7 with this version of httpclient.