When running "play" java.lang.NoSuchMethodError occurs - scala

I am trying to run a clone of the play project that I got from git clone https://github.com/djonmayer/play21-osm.git
I have play version 2.2.2 and scala version 2.10.4 installed.
When I type play in the directory that the project clones to I get the following error:
java.lang.NoSuchMethodError: scala.Predef$.augmentString(Ljava/lang/String;)Lscala/collection/immutable/StringOps;
at sbt.ConsoleLogger$.<init>(ConsoleLogger.scala:129)
at sbt.ConsoleLogger$.<clinit>(ConsoleLogger.scala)
at sbt.StandardMain$.<init>(Main.scala:52)
at sbt.StandardMain$.<clinit>(Main.scala)
at sbt.xMain.run(Main.scala:26)
at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:57)
at xsbt.boot.Launch$.withContextLoader(Launch.scala:77)
at xsbt.boot.Launch$.run(Launch.scala:57)
at xsbt.boot.Launch$$anonfun$explicit$1.apply(Launch.scala:45)
at xsbt.boot.Launch$.launch(Launch.scala:65)
at xsbt.boot.Launch$.apply(Launch.scala:16)
at xsbt.boot.Boot$.runImpl(Boot.scala:32)
at xsbt.boot.Boot$.main(Boot.scala:21)
at xsbt.boot.Boot.main(Boot.scala)
Error during sbt execution: java.lang.NoSuchMethodError: scala.Predef$.augmentString(Ljava/lang/String;)Lscala/collection/immutable/StringOps;
This is true if I run play clean. I have read this may be a dependencies issue so I have tried adding the line scalaVersion := "2.10.4" to the play.Project.settings section of Build.scala and separately in a build.sbt file. It didn't work.

I tried to put this in a comment but it was unreadable.
Thanks, zeppaman. It does look like this issue is to do with running a Play Framework project that was created in an older version of Play. By looking at another project that had commits for upgrading to a new play version I made the following changes.
In build.properties:
sbt.version=0.12.2
became:
sbt.version=0.13.0
In plugins.sbt:
addSbtPlugin("play" % "sbt-plugin" % "2.1.1")
became:
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.2.2")
This enabled me to get to play update then throws the errors:
[error] Modules were resolved with conflicting cross-version suffixes in {file:/Users/michaelrichardson/Documents/Play/play21-osm/}play21-osm:
[error] org.scala-stm:scala-stm _2.10, _2.10.0
[trace] Stack trace suppressed: run last *:update for the full output.
[error] (*:update) Conflicting cross-version suffixes in: org.scala-stm:scala-stm
I change the line in Build.scala:
"com.typesafe.play" %% "play-slick" % "0.3.2"
became:
"com.typesafe.play" %% "play-slick" % "0.5.0.2-SNAPSHOT"
EXTRA: This changes the error to:
[info] Resolving com.typesafe.play#play-slick_2.10;0.5.0.2-SNAPSHOT ...
[warn] module not found: com.typesafe.play#play-slick_2.10;0.5.0.2-SNAPSHOT
[warn] ==== Typesafe Releases Repository: tried
[warn] http://repo.typesafe.com/typesafe/releases/com/typesafe/play/play-slick_2.10/0.5.0.2-SNAPSHOT/play-slick_2.10-0.5.0.2-SNAPSHOT.pom
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: com.typesafe.play#play-slick_2.10;0.5.0.2-SNAPSHOT: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[trace] Stack trace suppressed: run last *:update for the full output.
[error] (*:update) sbt.ResolveException: unresolved dependency: com.typesafe.play#play-slick_2.10;0.5.0.2-SNAPSHOT: not found
UPDATE: Solved unresolved dependency
The problem of unresolved dependencies seems like it may have been due to my local sbt/ivy repositories getting corrupted. See unresolved dependency: com.typesafe.play#play-slick_2.10;0.6.0.1: not found

This kind of problem is often relate to two similar prolbem:
missing jar with same class
same class into multiple jar
So check if scala and play version are compatible and if You have included a jar that already contains the class with missing method.

Related

issue with resolving sbt dependencies scalameta

I have created an sbt project. I am trying to add the org.scalameta dependency for scala code formatting. I added following dependency in project/plugins.sbt
addSbtPlugin("org.scalameta" %% "scalameta_2.11" % "4.5.3")
But I am getting following error:
[warn] Note: Some unresolved dependencies have extra attributes. Check that these dependencies exist with the requested attributes.
[warn] org.scalameta:scalameta_2.11:4.5.3 (sbtVersion=1.0, scalaVersion=2.12)
[warn]
[warn] Note: Unresolved dependencies path:
[error] sbt.librarymanagement.ResolveException: Error downloading org.scalameta:scalameta_2.11;sbtVersion=1.0;scalaVersion=2.12:4.5.3
[error] Not found
[error] Not found
[error] not found: https://repo1.maven.org/maven2/org/scalameta/scalameta_2.11_2.12_1.0/4.5.3/scalameta_2.11-4.5.3.pom
If a double percent symbol (%%) is used, sbt will resolve the relevant Scala version.
A single percent symbol (%) is used to resolve the dependencies to a specific Scala version.
I just copy and pasted the example from Maven, and it worked for me:
libraryDependencies += "org.scalameta" %% "scalameta" % "4.5.3"
You can find an example within the Maven repository page.

SBT: SPARK2.0.*: SCALA: unresolved dependencies org.glassfish.hk2 and javax.validation

Unable to resolve dependencies while trying to use latest Apache Spark 2.0.2 and Scala 2.11.7 together
I need to use the latest version of spark since it has support for SparkSession. Below configuration working fine for spark 1.6.2. But I want for spark 2.0.*
This is my dependency configuration
scalaVersion := "2.11.7"
val sparkVersion = "2.0.2"
libraryDependencies ++= Seq(
ws ,
"org.apache.spark" %% "spark-core" % sparkVersion,
"org.apache.spark" %% "spark-sql" % sparkVersion,
"org.apache.spark" %% "spark-streaming" % sparkVersion,
"org.mongodb.spark" % "mongo-spark-connector_2.11" % "2.0.0",
specs2 % Test
)
And this is error message:
Error:Error while importing SBT project:
[info] Resolving org.ow2.asm#asm-tree;4.1 ...
[info] Resolving org.ow2.asm#asm-analysis;4.1 ...
[info] Resolving org.ow2.asm#asm-util;4.1 ...
[info] Resolving jline#jline;2.12.1 ...
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: org.glassfish.hk2#hk2-utils;2.22.2: not found
[warn] :: org.glassfish.hk2#hk2-locator;2.22.2: not found
[warn] :: javax.validation#validation-api;${javax.validation.version}: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[trace] Stack trace suppressed: run 'last *:update' for the full output.
[trace] Stack trace suppressed: run 'last *:ssExtractDependencies' for the full output.
[error] (*:update) sbt.ResolveException: unresolved dependency: org.glassfish.hk2#hk2-utils;2.22.2: not found
[error] unresolved dependency: org.glassfish.hk2#hk2-locator;2.22.2: not found
[error] unresolved dependency: javax.validation#validation-api;${javax.validation.version}: not found
[error] (*:ssExtractDependencies) sbt.ResolveException: unresolved dependency: org.glassfish.hk2#hk2-utils;2.22.2: not found
[error] unresolved dependency: org.glassfish.hk2#hk2-locator;2.22.2: not found
[error] unresolved dependency: javax.validation#validation-api;${javax.validation.version}: not found
[error] Total time: 81 s, completed 3 Dec, 2016 8:51:18 PM
Correct me if anything wrong in applying dependencies. Thank you
There's probably an error in the dependency publication chain. One option would be to exclude the broken dependencies - add exclude("org.glassfish.hk2", "hk2-utils") exclude("org.glassfish.hk2", "hk2-locator") exclude("javax.validation", "validation-api") to whatever Spark dependency that's bringing these in - and explicitly add the working versions of those three dependencies.
Also, I don't see version 2.22.2 for org.glassfish.hk2#hk2-utils or org.glassfish.hk2#hk2-locator.
Excluding at the org level (as suggested in How to exclude commons logging dependency of spring with ivy? ) helped me.
I had to use something like this :
<dependency org="org.glassfish.jersey.core" name="jersey-client" rev="2.3" conf="binaries->default">
<exclude org="org.glassfish.hk2"/>
</dependency>
<dependency org="org.glassfish.hk2" name="hk2-utils" rev="2.2.0-b14" conf="binaries->default"/>
<dependency org="org.glassfish.hk2" name="hk2-locator" rev="2.2.0-b14" conf="binaries->default"/>
<dependency org="org.glassfish.hk2" name="hk2-api" rev="2.2.0-b14" conf="binaries->default"/>

Dependency for cassandra phantom

I have following bulid.sbt
scalaVersion := "2.11.8"
libraryDependencies += "com.websudos" %% "diesel-engine" % "0.3.0"
libraryDependencies += "com.websudos" %% "phantom-dsl" % "1.27.0"
When sbt try resolve dependency following communicate is showing:
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: com.websudos#diesel-engine_2.11;0.3.0: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn]
[warn] Note: Unresolved dependencies path:
[warn] com.websudos:diesel-engine_2.11:0.3.0 (/path/build.sbt#L13-14)
[warn] +- com.websudos:phantom-dsl_2.11:1.27.0 (/path/build.sbt#L15-16)
[warn] +- default:webscraper_2.11:1.0
[trace] Stack trace suppressed: run last *:update for the full output.
[error] (*:update) sbt.ResolveException: unresolved dependency: com.websudos#diesel-engine_2.11;0.3.0: not found
[error] Total time: 2 s, completed 2016-07-11 18:19:22
The latest version of phantom available on Maven Central is 1.27.0. The diesel-engine does not get published to Maven Central at all, instead it gets published to our OSS Bintray repository.
resolvers += Resolver.bintrayRepo("websudos", "oss-releases") is the one you need to get diesel-engine to resolve properly. This is all described on the wiki page on integrating phantom, available here.
There is no such version on maven central. The oldest one is 1.5.0. If you really want to use the old one, try to download it from here adding this line to your sbt:
resolvers += Resolver.bintrayRepo("websudos", "oss-releases")

PlayFramework MongoDB Project Setup Failed

I tried setting up a new Play Framework on Scala and MongoDB. I tried all documentation available online, but each time I tried running the project on the terminal I get some obscure error. I have tried to make sense out of it, but all effort prove abortive. I am new Scala and Play Framework developer. Below is the response am getting from the terminal. Thanks
http://repo.typesafe.com/typesafe/releases/reactive_mongo_plugin/reactive_mongo_plugin_2.10/0.0.43/reactive_mongo_plugin_2.10-0.0.43.pom
[info] Resolving com.typesafe.trace#trace-sigar-libs;0.1.1 ...
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: reactive_mongo_plugin#reactive_mongo_plugin_2.10;0.0.43: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[trace] Stack trace suppressed: run last *:update for the full output.
[error] (*:update) sbt.ResolveException: unresolved dependency: reactive_mongo_plugin#reactive_mongo_plugin_2.10;0.0.43: not found
[error] Total time: 36 s, completed Apr 4, 2015 10:04:19 AM
I guess you try to use the Play plugin, but the dependency doesn't correspond to this lib whose latest artifact is "org.reactivemongo" %% "play2-reactivemongo" % "0.10.5.0.akka23": http://search.maven.org/#search%7Cga%7C1%7Creactivemongo

SBT won't resolve fakehttpserver dependency because of bad commons pom file

I'm trying to use this fake http server project in a sbt 0.11.0 based project. Unfortunately one of it's dependencies is giving the following error:
[error] public: bad organisation found in http://repo1.maven.org/maven2/org/apache/commons/commons-io/1.3.2/commons-io-1.3.2.pom: expected='org.apache.commons' found='commons-io'
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: org.apache.commons#commons-io;1.3.2: java.text.ParseException: inconsistent module descriptor file found in 'http://repo1.maven.org/maven2/org/apache/commons/commons-io/1.3.2/commons-io-1.3.2.pom': bad organisation: expected='org.apache.commons' found='commons-io';
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[error] {file:/home/project_location/}default-db401d/*:update: sbt.ResolveException: unresolved dependency: org.apache.commons#commons-io;1.3.2: java.text.ParseException: inconsistent module descriptor file found in 'http://repo1.maven.org/maven2/org/apache/commons/commons-io/1.3.2/commons-io-1.3.2.pom': bad organisation: expected='org.apache.commons' found='commons-io';
From what I can tell this can be worked around by asking that ivy not check the consistency of the pom files (Maven has this setting off by default). I can't work out how to turn this off in sbt though. I tried
ivyValidate := false
but this has no effect.
Am I on the right track with this setting and is it possible to turn this setting off?
You could try to exclude this dependency and include it manually :
"se.dannej" % "fakehttpserver" % "0.1.0" exclude("org.apache.commons", "commons-io")
"commons-io" % "commons-io" % "another version"
or even download the commons-io jar and push it in your lib directory.