Skip to content
This repository has been archived by the owner on Feb 28, 2021. It is now read-only.

Running sbt publish fails due to NoSuchMethodError #104

Closed
pdolega opened this issue Apr 23, 2017 · 11 comments
Closed

Running sbt publish fails due to NoSuchMethodError #104

pdolega opened this issue Apr 23, 2017 · 11 comments

Comments

@pdolega
Copy link

pdolega commented Apr 23, 2017

I think it's due to conflicting dependency on this lib (json-native should be in 3.2.10):

[info] Loading project definition from /home/pdolega/projects/lambda/quartercask/project
[info] Updating {file:/home/pdolega/projects/lambda/quartercask/project/}quartercask-build...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] downloading https://repo1.maven.org/maven2/org/json4s/json4s-native_2.10/3.2.11/json4s-native_2.10-3.2.11.jar ...

My build.sbt (I tried to enforce 3.2.10 but with no luck...):

val projectVersion          = "0.1"
val projectOrg              = "codes.bytes"
val awsSdkVersion           = "1.11.119"
val alexaSkillsVersion      = "1.1.2"

//excludeDependencies ++= Seq(
//  "org.json4s"    %% "json4s-jackson" % "3.2.11",
//  "org.json4s"    %% "json4s-native" % "3.2.11"
//)

dependencyOverrides += "org.json4s" %% "json4s-native" % "3.2.10"

lazy val commonSettings = Seq(
  organization := projectOrg,
  version := projectVersion,
  retrieveManaged := true,
  libraryDependencies ++= Seq(
    "org.json4s"    %% "json4s-native"            % "3.2.10" force()
  ),
  excludeDependencies ++= Seq(
    "org.json4s"    %% "json4s-jackson",
    "org.json4s"    %% "json4s-native"
  ),
  dependencyOverrides += "org.json4s" %% "json4s-native" % "3.2.10",
  retrieveManaged := true,
  scalacOptions := Seq(
    "-encoding", "UTF-8",
    "-target:jvm-1.7",
    "-deprecation",
    "-language:_"
  ),

  bintrayOrganization := Some("quaich"),
  licenses += ("MIT", url("http://opensource.org/licenses/MIT")),

  fork in (Test, run) := true,

  addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.4" exclude("org.json4s", "json4s-native"))
)

and my plugins.sbt:

addSbtPlugin("org.foundweekends" % "sbt-bintray" % "0.4.0"  exclude("org.json4s", "json4s-native"))
//addSbtPlugin("me.lessis" % "bintray-sbt" % "0.3.0")

resolvers += Resolver.jcenterRepo

Error is attached below:

java.lang.NoSuchMethodError: org.json4s.Formats.emptyValueStrategy()Lorg/json4s/prefs/EmptyValueStrategy;
        at org.json4s.native.JsonMethods$class.render(JsonMethods.scala:29)
        at org.json4s.native.JsonMethods$.render(JsonMethods.scala:62)
        at bintry.Methods$json$.str(Methods.scala:19)
        at bintry.Methods$Repo$Package$Version$Attrs$.update(Methods.scala:147)
        at bintray.BintrayRepo$$anonfun$publishVersionAttributes$1.apply(BintrayRepo.scala:23)
        at bintray.BintrayRepo$$anonfun$publishVersionAttributes$1.apply(BintrayRepo.scala:23)
        at bintray.Bintray$await$.ready(Bintray.scala:119)
        at bintray.BintrayRepo.publishVersionAttributes(BintrayRepo.scala:22)
        at bintray.BintrayPlugin$$anonfun$publishVersionAttributesTask$1.apply(BintrayPlugin.scala:149)
        at bintray.BintrayPlugin$$anonfun$publishVersionAttributesTask$1.apply(BintrayPlugin.scala:147)
        at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
        at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
        at sbt.std.Transform$$anon$4.work(System.scala:63)
        at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
        at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
        at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
        at sbt.Execute.work(Execute.scala:237)
        at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
        at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
        at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
...
@pdolega
Copy link
Author

pdolega commented Apr 23, 2017

BTW it seems that after downgrading to:

addSbtPlugin("me.lessis" % "bintray-sbt" % "0.3.0")

it works fine.

@queirozfcom
Copy link

I also have this issue - also downgraded.

@EmilDafinov
Copy link

Same here, trying the downgrade...

EmilDafinov pushed a commit to EmilDafinov/scala-ad-sdk that referenced this issue Apr 28, 2017
@philmcmahon
Copy link

We've found the same issue and tried to resolve it by adding the same dependency override (dependencyOverrides += "org.json4s" %% "json4s-native" % "3.2.10") but in plugins.sbt instead of build.sbt. This revealed that bintray 0.4 has a dependency on a method that only exists in 3.2.11 😞 .

Here's the new stack trace when forcing to 3.2.10:

java.lang.NoSuchMethodError: org.json4s.native.JsonMethods$.render$default$2(Lorg/json4s/JsonAST$JValue;)Lorg/json4s/Formats;
	at bintry.Methods$json$.str(Methods.scala:19)
	at bintry.Methods$Repo$Package$Version$Attrs$.update(Methods.scala:147)
	at bintray.BintrayRepo$$anonfun$publishVersionAttributes$1.apply(BintrayRepo.scala:23)
	at bintray.BintrayRepo$$anonfun$publishVersionAttributes$1.apply(BintrayRepo.scala:23)
	at bintray.Bintray$await$.ready(Bintray.scala:119)
	at bintray.BintrayRepo.publishVersionAttributes(BintrayRepo.scala:22)
	at bintray.BintrayPlugin$$anonfun$publishVersionAttributesTask$1.apply(BintrayPlugin.scala:149)
	at bintray.BintrayPlugin$$anonfun$publishVersionAttributesTask$1.apply(BintrayPlugin.scala:147)
	at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
	at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
	at sbt.std.Transform$$anon$4.work(System.scala:63)
	at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
	at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
	at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
	at sbt.Execute.work(Execute.scala:237)
	at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
	at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
	at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
	at sbt.CompletionService$$anon$2.call(CompletionService.scala:28)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)

@dwijnand
Copy link
Member

The cause of this is dispatch-json4s-native 0.11.3 isn't backwards binary compatible with 0.11.2.

In bintry (the library behind sbt-bintray) the dependency on dispatch-json4s-native was:

And then nothing was done about the situation and sbt-bintray 0.4.0 was cut.

@BenFradet
Copy link

Is the recommended course of action downgrading then?

@dwijnand
Copy link
Member

Yes. But in the same breath I invite anyone suffering this issue to consider contributing a fix which includes a regression test that represents the reason for the forced downgrade. That way we can avoid future regressions of this issue.

@jeffmay
Copy link

jeffmay commented May 17, 2017

To fix the underlying issue, I think the solution is to upgrade, not downgrade.

According to this issue, they did not have binary compatibility checking turned on at the time:
json4s/json4s#212

We should try to use the same version of the library in all transitive dependencies (assuming you can get the owners to upgrade ...) Since bintry is using version 3.5.1, I think we should bump all the json4s versions to 3.5.1.

As far as regression tests go, I don't see any scripted sbt tests in this repo. It much harder to get that started than to add to it, so I would encourage the owner of this project to help get that started.

@pdolega
Copy link
Author

pdolega commented May 19, 2017

OK - as I have started this issue it is kind of proper for me to at least attempt to fix it. Two PRs with the fix above. It solves the issue but that is definitely not a perfect fix :/ (I wasn't able to reproduce it in unit tests - here are more details: sbt/bintry#28 )

@pdolega
Copy link
Author

pdolega commented May 21, 2017

By the way @jeffmay - i think that problem with idea of upgrading is that there are some dependencies that use 3.2.x (namely i am talking about dispatch-json4s-native). Now, there are newer versions of dispatch-json4s-native that use newer dependency versions but they are not built for Scala 2.10 (which is required by sbt) :/ This would be resolved to some extent when sbt 1.x is released (and when we have more sbt plugins built against it).

The downgrading change has been merged, we are lacking couple of steps now:

On top of this we obviously need to have PR merged here ( #108 ) and publishing done.

This process already contains multiple steps, I am a little worried that adding yet more dependent changes (PRs + publishing process) would make this a very long fix. That said - I 100% agree that, long term, what you say is the best solution.

@pdolega
Copy link
Author

pdolega commented May 24, 2017

OK @dwijnand / @jeffmay I managed to create a test on PR mentiond above ( #108 ) which fully reproduces the issue (with sbt-scripted ). I do have however a problem here with dealing with cross plugin build for 1.0.0-M5 (everything works just fine for 0.x ).

Asking for a friend basically here :) @eed3si9n / @romanowski maybe you guys could help?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants